From b7eb7ff8e3d3bdafb500346117db13a907e00646 Mon Sep 17 00:00:00 2001 From: k1ll Date: Thu, 15 Mar 2012 15:51:39 +0100 Subject: [PATCH 01/23] Added support for linking static Ogre libraries and plugins into the launcher and openmw. --- CMakeLists.txt | 10 +++- apps/launcher/CMakeLists.txt | 10 ++++ apps/launcher/graphicspage.cpp | 13 +++++ apps/launcher/graphicspage.hpp | 14 ++++++ apps/openmw/CMakeLists.txt | 10 ++++ cmake/FindOGRE.cmake | 84 +++++++++++++++---------------- libs/openengine/ogre/renderer.cpp | 34 +++++++++++++ libs/openengine/ogre/renderer.hpp | 40 +++++++++++++++ 8 files changed, 172 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9c60e554..bfa6dd8b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,8 +189,16 @@ find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread) find_package(OIS REQUIRED) find_package(OpenAL REQUIRED) find_package(Bullet REQUIRED) +IF(OGRE_STATIC) +find_package(Cg REQUIRED) +IF(WIN32) +set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_Direct3D9_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS}) +ELSE(WIN32) +set(OGRE_PLUGIN_INCLUDE_DIRS ${OGRE_Plugin_CgProgramManager_INCLUDE_DIRS} ${OGRE_Plugin_OctreeSceneManager_INCLUDE_DIRS} ${OGRE_Plugin_ParticleFX_INCLUDE_DIRS} ${OGRE_RenderSystem_GL_INCLUDE_DIRS}) +ENDIF(WIN32) +ENDIF(OGRE_STATIC) include_directories("." - ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE + ${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_PLUGIN_INCLUDE_DIRS} ${OIS_INCLUDE_DIRS} ${Boost_INCLUDE_DIR} ${PLATFORM_INCLUDE_DIR} ${CMAKE_HOME_DIRECTORY}/extern/mygui_3.0.1/MyGUIEngine/include diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index a34ad7429..fd736e011 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -53,6 +53,15 @@ QT4_WRAP_CPP(MOC_SRCS ${LAUNCHER_HEADER_MOC}) include(${QT_USE_FILE}) # Main executable +IF(OGRE_STATIC) +IF(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ELSE(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_RenderSystem_GL_LIBRARIES}) +ENDIF(WIN32) +ENDIF(OGRE_STATIC) add_executable(omwlauncher ${GUI_TYPE} ${LAUNCHER} @@ -63,6 +72,7 @@ add_executable(omwlauncher target_link_libraries(omwlauncher ${Boost_LIBRARIES} ${OGRE_LIBRARIES} + ${OGRE_STATIC_PLUGINS} ${QT_LIBRARIES} components ) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index b7d397f06..95b38d53e 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -186,7 +186,11 @@ void GraphicsPage::setupOgre() try { + #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) + mOgre = new Ogre::Root("", file.fileName().toStdString(), "./launcherOgre.log"); + #else mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log"); + #endif } catch(Ogre::Exception &ex) { @@ -207,6 +211,15 @@ void GraphicsPage::setupOgre() return; } + #ifdef ENABLE_PLUGIN_GL + mGLPlugin = new Ogre::GLPlugin(); + mOgre->installPlugin(mGLPlugin); + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + mD3D9Plugin = new Ogre::D3D9Plugin(); + mOgre->installPlugin(mD3D9Plugin); + #endif + // Get the available renderers and put them in the combobox const Ogre::RenderSystemList &renderers = mOgre->getAvailableRenderers(); diff --git a/apps/launcher/graphicspage.hpp b/apps/launcher/graphicspage.hpp index bdfd4f038..6a91a0628 100644 --- a/apps/launcher/graphicspage.hpp +++ b/apps/launcher/graphicspage.hpp @@ -8,6 +8,14 @@ #include #include +// Static plugin headers +#ifdef ENABLE_PLUGIN_GL +# include "OgreGLPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_Direct3D9 +# include "OgreD3D9Plugin.h" +#endif + class QComboBox; class QCheckBox; class QStackedWidget; @@ -32,6 +40,12 @@ private: Ogre::RenderSystem *mSelectedRenderSystem; Ogre::RenderSystem *mOpenGLRenderSystem; Ogre::RenderSystem *mDirect3DRenderSystem; + #ifdef ENABLE_PLUGIN_GL + Ogre::GLPlugin* mGLPlugin; + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + Ogre::D3D9Plugin* mD3D9Plugin; + #endif QComboBox *mRendererComboBox; diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 77f465b4c..6d33298df 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -57,6 +57,15 @@ add_openmw_dir (mwmechanics ) # Main executable +IF(OGRE_STATIC) +IF(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ELSE(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ENDIF(WIN32) +ENDIF(OGRE_STATIC) add_executable(openmw ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} ${COMPONENT_FILES} @@ -72,6 +81,7 @@ add_definitions(${SOUND_DEFINE}) target_link_libraries(openmw ${OGRE_LIBRARIES} + ${OGRE_STATIC_PLUGINS} ${OIS_LIBRARIES} ${Boost_LIBRARIES} ${OPENAL_LIBRARY} diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 917a8653e..fd292ddeb 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -18,7 +18,7 @@ # Once done, this will define # # OGRE_FOUND - system has OGRE -# OGRE_INCLUDE_DIRS - the OGRE include directories +# OGRE_INCLUDE_DIRS - the OGRE include directories # OGRE_LIBRARIES - link these to use the OGRE core # OGRE_BINARY_REL - location of the main Ogre binary (win32 non-static only, release) # OGRE_BINARY_DBG - location of the main Ogre binaries (win32 non-static only, debug) @@ -28,15 +28,14 @@ # Plugin_BSPSceneManager, Plugin_CgProgramManager, # Plugin_OctreeSceneManager, Plugin_OctreeZone, # Plugin_ParticleFX, Plugin_PCZSceneManager, -# RenderSystem_GL, RenderSystem_Direct3D9, +# RenderSystem_GL, RenderSystem_Direct3D9, RenderSystem_Direct3D10, # Paging, Terrain # # For each of these components, the following variables are defined: # - # OGRE_${COMPONENT}_FOUND - ${COMPONENT} is available # OGRE_${COMPONENT}_INCLUDE_DIRS - additional include directories for ${COMPONENT} -# OGRE_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT} +# OGRE_${COMPONENT}_LIBRARIES - link these to use ${COMPONENT} # OGRE_${COMPONENT}_BINARY_REL - location of the component binary (win32 non-static only, release) # OGRE_${COMPONENT}_BINARY_DBG - location of the component binary (win32 non-static only, debug) # @@ -113,7 +112,7 @@ if (OGRE_PREFIX_SOURCE AND OGRE_PREFIX_BUILD) set(OGRE_BIN_SEARCH_PATH ${dir}/bin ${OGRE_BIN_SEARCH_PATH}) set(OGRE_BIN_SEARCH_PATH ${dir}/Samples/Common/bin ${OGRE_BIN_SEARCH_PATH}) endforeach(dir) - + if (OGRE_PREFIX_DEPENDENCIES_DIR) set(OGRE_INC_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/include ${OGRE_INC_SEARCH_PATH}) set(OGRE_LIB_SEARCH_PATH ${OGRE_PREFIX_DEPENDENCIES_DIR}/lib ${OGRE_LIB_SEARCH_PATH}) @@ -125,12 +124,12 @@ else() endif () # redo search if any of the environmental hints changed -set(OGRE_COMPONENTS Paging Terrain +set(OGRE_COMPONENTS Paging Terrain Plugin_BSPSceneManager Plugin_CgProgramManager Plugin_OctreeSceneManager Plugin_OctreeZone Plugin_PCZSceneManager Plugin_ParticleFX - RenderSystem_Direct3D11 RenderSystem_Direct3D9 RenderSystem_GL RenderSystem_GLES RenderSystem_GLES2) -set(OGRE_RESET_VARS - OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR + RenderSystem_Direct3D10 RenderSystem_Direct3D9 RenderSystem_GL RenderSystem_GLES) +set(OGRE_RESET_VARS + OGRE_CONFIG_INCLUDE_DIR OGRE_INCLUDE_DIR OGRE_LIBRARY_FWK OGRE_LIBRARY_REL OGRE_LIBRARY_DBG OGRE_PLUGIN_DIR_DBG OGRE_PLUGIN_DIR_REL OGRE_MEDIA_DIR) foreach (comp ${OGRE_COMPONENTS}) @@ -145,7 +144,7 @@ clear_if_changed(OGRE_PREFIX_WATCH ${OGRE_RESET_VARS}) # try to locate Ogre via pkg-config use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}") -if(NOT OGRE_BUILD_PLATFORM_APPLE_IOS) +if(NOT OGRE_BUILD_PLATFORM_IPHONE) # try to find framework on OSX findpkg_framework(OGRE) else() @@ -236,7 +235,6 @@ if (OGRE_STATIC) find_package(Freetype QUIET) find_package(OpenGL QUIET) find_package(OpenGLES QUIET) - find_package(OpenGLES2 QUIET) find_package(ZLIB QUIET) find_package(ZZip QUIET) if (UNIX AND NOT APPLE) @@ -246,26 +244,28 @@ if (OGRE_STATIC) set(X11_FOUND FALSE) endif () endif () - if (APPLE AND NOT OGRE_BUILD_PLATFORM_APPLE_IOS) + if (APPLE AND NOT OGRE_BUILD_PLATFORM_IPHONE) find_package(Cocoa QUIET) find_package(Carbon QUIET) - find_package(CoreVideo QUIET) - if (NOT Cocoa_FOUND OR NOT Carbon_FOUND OR NOT CoreVideo_FOUND) + if (NOT Cocoa_FOUND OR NOT Carbon_FOUND) set(OGRE_DEPS_FOUND FALSE) endif () endif () - if (APPLE AND OGRE_BUILD_PLATFORM_APPLE_IOS) + if (APPLE AND OGRE_BUILD_PLATFORM_IPHONE) find_package(iPhoneSDK QUIET) if (NOT iPhoneSDK_FOUND) set(OGRE_DEPS_FOUND FALSE) endif () endif () - set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} ) - - if (APPLE AND NOT OGRE_BUILD_PLATFORM_APPLE_IOS) - set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} ${Carbon_LIBRARIES} ${Cocoa_LIBRARIES}) - endif() + #set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} + # ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} + # ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} + # ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) + set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} + ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} + ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} + ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) if (NOT ZLIB_FOUND OR NOT ZZip_FOUND) set(OGRE_DEPS_FOUND FALSE) @@ -309,7 +309,7 @@ if (OGRE_STATIC) endif () endif () endif () - + if (NOT OGRE_DEPS_FOUND) pkg_message(OGRE "Could not find all required dependencies for the Ogre package.") set(OGRE_FOUND FALSE) @@ -341,7 +341,7 @@ endif() # Find Ogre components ######################################################### -set(OGRE_COMPONENT_SEARCH_PATH_REL +set(OGRE_COMPONENT_SEARCH_PATH_REL ${OGRE_LIBRARY_DIR_REL}/.. ${OGRE_LIBRARY_DIR_REL}/../.. ${OGRE_BIN_SEARCH_PATH} @@ -393,17 +393,17 @@ macro(ogre_find_plugin PLUGIN HEADER) set(TMP_CMAKE_LIB_PREFIX ${CMAKE_FIND_LIBRARY_PREFIXES}) set(CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES} "") endif() - + # strip RenderSystem_ or Plugin_ prefix from plugin name string(REPLACE "RenderSystem_" "" PLUGIN_TEMP ${PLUGIN}) string(REPLACE "Plugin_" "" PLUGIN_NAME ${PLUGIN_TEMP}) - + # header files for plugins are not usually needed, but find them anyway if they are present set(OGRE_PLUGIN_PATH_SUFFIXES - PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN} + PlugIns PlugIns/${PLUGIN_NAME} Plugins Plugins/${PLUGIN_NAME} ${PLUGIN} RenderSystems RenderSystems/${PLUGIN_NAME} ${ARGN}) - find_path(OGRE_${PLUGIN}_INCLUDE_DIR NAMES ${HEADER} - HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} + find_path(OGRE_${PLUGIN}_INCLUDE_DIR NAMES ${HEADER} + HINTS ${OGRE_INCLUDE_DIRS} ${OGRE_PREFIX_SOURCE} PATH_SUFFIXES ${OGRE_PLUGIN_PATH_SUFFIXES}) # find link libraries for plugins set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}") @@ -429,7 +429,7 @@ macro(ogre_find_plugin PLUGIN HEADER) if (OGRE_${PLUGIN}_FOUND) if (NOT OGRE_PLUGIN_DIR_REL OR NOT OGRE_PLUGIN_DIR_DBG) if (WIN32) - set(OGRE_PLUGIN_SEARCH_PATH_REL + set(OGRE_PLUGIN_SEARCH_PATH_REL ${OGRE_LIBRARY_DIR_REL}/.. ${OGRE_LIBRARY_DIR_REL}/../.. ${OGRE_BIN_SEARCH_PATH} @@ -445,12 +445,12 @@ macro(ogre_find_plugin PLUGIN HEADER) PATH_SUFFIXES "" bin bin/debug debug) elseif (UNIX) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_REL} PATH) - set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)" FORCE) + set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)") get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_DBG} PATH) - set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)" FORCE) + set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)") endif () endif () - + # find binaries if (NOT OGRE_STATIC) if (WIN32) @@ -459,7 +459,7 @@ macro(ogre_find_plugin PLUGIN HEADER) endif() mark_as_advanced(OGRE_${PLUGIN}_REL OGRE_${PLUGIN}_DBG) endif() - + endif () if (TMP_CMAKE_LIB_PREFIX) @@ -475,8 +475,8 @@ ogre_find_plugin(Plugin_OctreeSceneManager OgreOctreeSceneManager.h PlugIns/Octr ogre_find_plugin(Plugin_ParticleFX OgreParticleFXPrerequisites.h PlugIns/ParticleFX/include) ogre_find_plugin(RenderSystem_GL OgreGLRenderSystem.h RenderSystems/GL/include) ogre_find_plugin(RenderSystem_GLES OgreGLESRenderSystem.h RenderSystems/GLES/include) -ogre_find_plugin(RenderSystem_GLES2 OgreGLES2RenderSystem.h RenderSystems/GLES2/include) ogre_find_plugin(RenderSystem_Direct3D9 OgreD3D9RenderSystem.h RenderSystems/Direct3D9/include) +ogre_find_plugin(RenderSystem_Direct3D10 OgreD3D10RenderSystem.h RenderSystems/Direct3D10/include) ogre_find_plugin(RenderSystem_Direct3D11 OgreD3D11RenderSystem.h RenderSystems/Direct3D11/include) if (OGRE_STATIC) @@ -484,26 +484,28 @@ if (OGRE_STATIC) if (NOT DirectX_FOUND) set(OGRE_RenderSystem_Direct3D9_FOUND FALSE) endif () + if (NOT DirectX_D3D10_FOUND) + set(OGRE_RenderSystem_Direct3D10_FOUND FALSE) + endif () if (NOT DirectX_D3D11_FOUND) set(OGRE_RenderSystem_Direct3D11_FOUND FALSE) endif () if (NOT OPENGL_FOUND) set(OGRE_RenderSystem_GL_FOUND FALSE) endif () - if (NOT OPENGLES_FOUND) + if (NOT OPENGLES_FOUND AND NOT OPENGLES2_FOUND) set(OGRE_RenderSystem_GLES_FOUND FALSE) endif () - if (NOT OPENGLES2_FOUND) - set(OGRE_RenderSystem_GLES2_FOUND FALSE) - endif () if (NOT Cg_FOUND) set(OGRE_Plugin_CgProgramManager_FOUND FALSE) endif () - + set(OGRE_RenderSystem_Direct3D9_LIBRARIES ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${DirectX_LIBRARIES} ) - + set(OGRE_RenderSystem_Direct3D10_LIBRARIES ${OGRE_RenderSystem_Direct3D10_LIBRARIES} + ${DirectX_D3D10_LIBRARIES} + ) set(OGRE_RenderSystem_Direct3D11_LIBRARIES ${OGRE_RenderSystem_Direct3D11_LIBRARIES} ${DirectX_D3D11_LIBRARIES} ) @@ -513,9 +515,6 @@ if (OGRE_STATIC) set(OGRE_RenderSystem_GLES_LIBRARIES ${OGRE_RenderSystem_GLES_LIBRARIES} ${OPENGLES_LIBRARIES} ) - set(OGRE_RenderSystem_GLES2_LIBRARIES ${OGRE_RenderSystem_GLES2_LIBRARIES} - ${OPENGLES2_LIBRARIES} - ) set(OGRE_Plugin_CgProgramManager_LIBRARIES ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ) @@ -540,3 +539,4 @@ set(OGRE_MEDIA_SEARCH_SUFFIX clear_if_changed(OGRE_PREFIX_WATCH OGRE_MEDIA_DIR) find_path(OGRE_MEDIA_DIR NAMES packs/cubemapsJS.zip HINTS ${OGRE_MEDIA_SEARCH_PATH} PATHS ${OGRE_PREFIX_PATH} PATH_SUFFIXES ${OGRE_MEDIA_SEARCH_SUFFIX}) + diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index ecded08d8..f2a23c831 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -26,6 +26,35 @@ void OgreRenderer::start() mRoot->startRendering(); } +bool OgreRenderer::loadPlugins() +{ + #ifdef ENABLE_PLUGIN_GL + mGLPlugin = new Ogre::GLPlugin(); + mRoot->installPlugin(mGLPlugin); + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + mD3D9Plugin = new Ogre::D3D9Plugin(); + mRoot->installPlugin(mD3D9Plugin); + #endif + #ifdef ENABLE_PLUGIN_CgProgramManager + mCgPlugin = new Ogre::CgPlugin(); + mRoot->installPlugin(mCgPlugin); + #endif + #ifdef ENABLE_PLUGIN_OctreeSceneManager + mOctreePlugin = new Ogre::OctreePlugin(); + mRoot->installPlugin(mOctreePlugin); + #endif + #ifdef ENABLE_PLUGIN_ParticleFX + mParticleFXPlugin = new Ogre::ParticleFXPlugin(); + mRoot->installPlugin(mParticleFXPlugin); + #endif + #ifdef ENABLE_PLUGIN_BSPSceneManager + mBSPPlugin = new Ogre::BspSceneManagerPlugin(); + mRoot->installPlugin(mBSPPlugin); + #endif + return true; +} + void OgreRenderer::update(float dt) { mFader->update(dt); @@ -59,7 +88,12 @@ bool OgreRenderer::configure(bool showConfig, // Disable logging log->setDebugOutputEnabled(false); +#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) || defined(ENABLE_PLUGIN_BSPSceneManager) + mRoot = new Root("", cfgPath, ""); + loadPlugins(); +#else mRoot = new Root(pluginCfg, cfgPath, ""); +#endif // Show the configuration dialog and initialise the system, if the // showConfig parameter is specified. The settings are stored in diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index f48383cbc..fa7435501 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -7,6 +7,26 @@ #include +// Static plugin headers +#ifdef ENABLE_PLUGIN_CgProgramManager +# include "OgreCgPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_OctreeSceneManager +# include "OgreOctreePlugin.h" +#endif +#ifdef ENABLE_PLUGIN_ParticleFX +# include "OgreParticleFXPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_BSPSceneManager +# include "OgreBspSceneManagerPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_GL +# include "OgreGLPlugin.h" +#endif +#ifdef ENABLE_PLUGIN_Direct3D9 +# include "OgreD3D9Plugin.h" +#endif + namespace Ogre { class Root; @@ -27,6 +47,24 @@ namespace Render Ogre::SceneManager *mScene; Ogre::Camera *mCamera; Ogre::Viewport *mView; + #ifdef ENABLE_PLUGIN_CgProgramManager + Ogre::CgPlugin* mCgPlugin; + #endif + #ifdef ENABLE_PLUGIN_OctreeSceneManager + Ogre::OctreePlugin* mOctreePlugin; + #endif + #ifdef ENABLE_PLUGIN_ParticleFX + Ogre::ParticleFXPlugin* mParticleFXPlugin; + #endif + #ifdef ENABLE_PLUGIN_BSPSceneManager + Ogre::BspSceneManagerPlugin* mBSPPlugin; + #endif + #ifdef ENABLE_PLUGIN_GL + Ogre::GLPlugin* mGLPlugin; + #endif + #ifdef ENABLE_PLUGIN_Direct3D9 + Ogre::D3D9Plugin* mD3D9Plugin; + #endif Fader* mFader; bool logging; @@ -68,6 +106,8 @@ namespace Render /// Start the main rendering loop void start(); + + bool loadPlugins(); void update(float dt); From c5bbbee9c1ffaa0c956335fd682f5bb88d8d72e4 Mon Sep 17 00:00:00 2001 From: k1ll Date: Thu, 15 Mar 2012 21:37:55 +0100 Subject: [PATCH 02/23] Added needed cmake files and added a comment to clarify the changes in FindOgre.cmake --- cmake/FindCg.cmake | 53 +++++++++++++++++++++++++++++++++++++++ cmake/FindFreeImage.cmake | 47 ++++++++++++++++++++++++++++++++++ cmake/FindOGRE.cmake | 1 + cmake/FindZZip.cmake | 48 +++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 cmake/FindCg.cmake create mode 100644 cmake/FindFreeImage.cmake create mode 100644 cmake/FindZZip.cmake diff --git a/cmake/FindCg.cmake b/cmake/FindCg.cmake new file mode 100644 index 000000000..4bd348c46 --- /dev/null +++ b/cmake/FindCg.cmake @@ -0,0 +1,53 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find Cg +# Once done, this will define +# +# Cg_FOUND - system has Cg +# Cg_INCLUDE_DIRS - the Cg include directories +# Cg_LIBRARIES - link these to use Cg + +include(FindPkgMacros) +findpkg_begin(Cg) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(Cg_HOME) +getenv_path(OGRE_SOURCE) +getenv_path(OGRE_HOME) + +# construct search paths +set(Cg_PREFIX_PATH ${Cg_HOME} ${ENV_Cg_HOME} + ${OGRE_SOURCE}/Dependencies + ${ENV_OGRE_SOURCE}/Dependencies + ${OGRE_HOME} ${ENV_OGRE_HOME} + /opt/nvidia-cg-toolkit) +create_search_paths(Cg) +# redo search if prefix path changed +clear_if_changed(Cg_PREFIX_PATH + Cg_LIBRARY_FWK + Cg_LIBRARY_REL + Cg_LIBRARY_DBG + Cg_INCLUDE_DIR +) + +set(Cg_LIBRARY_NAMES Cg) +get_debug_names(Cg_LIBRARY_NAMES) + +use_pkgconfig(Cg_PKGC Cg) + +findpkg_framework(Cg) + +find_path(Cg_INCLUDE_DIR NAMES cg.h HINTS ${Cg_FRAMEWORK_INCLUDES} ${Cg_INC_SEARCH_PATH} ${Cg_PKGC_INCLUDE_DIRS} PATH_SUFFIXES Cg) +find_library(Cg_LIBRARY_REL NAMES ${Cg_LIBRARY_NAMES} HINTS ${Cg_LIB_SEARCH_PATH} ${Cg_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(Cg_LIBRARY_DBG NAMES ${Cg_LIBRARY_NAMES_DBG} HINTS ${Cg_LIB_SEARCH_PATH} ${Cg_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) +make_library_set(Cg_LIBRARY) + +findpkg_finish(Cg) +add_parent_dir(Cg_INCLUDE_DIRS Cg_INCLUDE_DIR) diff --git a/cmake/FindFreeImage.cmake b/cmake/FindFreeImage.cmake new file mode 100644 index 000000000..3b21a17d6 --- /dev/null +++ b/cmake/FindFreeImage.cmake @@ -0,0 +1,47 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find FreeImage +# Once done, this will define +# +# FreeImage_FOUND - system has FreeImage +# FreeImage_INCLUDE_DIRS - the FreeImage include directories +# FreeImage_LIBRARIES - link these to use FreeImage + +include(FindPkgMacros) +findpkg_begin(FreeImage) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(FREEIMAGE_HOME) + +# construct search paths +set(FreeImage_PREFIX_PATH ${FREEIMAGE_HOME} ${ENV_FREEIMAGE_HOME}) +create_search_paths(FreeImage) +# redo search if prefix path changed +clear_if_changed(FreeImage_PREFIX_PATH + FreeImage_LIBRARY_FWK + FreeImage_LIBRARY_REL + FreeImage_LIBRARY_DBG + FreeImage_INCLUDE_DIR +) + +set(FreeImage_LIBRARY_NAMES freeimage) +get_debug_names(FreeImage_LIBRARY_NAMES) + +use_pkgconfig(FreeImage_PKGC freeimage) + +findpkg_framework(FreeImage) + +find_path(FreeImage_INCLUDE_DIR NAMES FreeImage.h HINTS ${FreeImage_INC_SEARCH_PATH} ${FreeImage_PKGC_INCLUDE_DIRS}) +find_library(FreeImage_LIBRARY_REL NAMES ${FreeImage_LIBRARY_NAMES} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(FreeImage_LIBRARY_DBG NAMES ${FreeImage_LIBRARY_NAMES_DBG} HINTS ${FreeImage_LIB_SEARCH_PATH} ${FreeImage_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) +make_library_set(FreeImage_LIBRARY) + +findpkg_finish(FreeImage) + diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index fd292ddeb..2c07a4d55 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -258,6 +258,7 @@ if (OGRE_STATIC) endif () endif () + #Removed FWK because it normally is unnecessary and would break the build when not available #set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} # ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} # ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} diff --git a/cmake/FindZZip.cmake b/cmake/FindZZip.cmake new file mode 100644 index 000000000..68fe043f3 --- /dev/null +++ b/cmake/FindZZip.cmake @@ -0,0 +1,48 @@ +#------------------------------------------------------------------- +# This file is part of the CMake build system for OGRE +# (Object-oriented Graphics Rendering Engine) +# For the latest info, see http://www.ogre3d.org/ +# +# The contents of this file are placed in the public domain. Feel +# free to make use of it in any way you like. +#------------------------------------------------------------------- + +# - Try to find zziplib +# Once done, this will define +# +# ZZip_FOUND - system has ZZip +# ZZip_INCLUDE_DIRS - the ZZip include directories +# ZZip_LIBRARIES - link these to use ZZip + +include(FindPkgMacros) +findpkg_begin(ZZip) + +# Get path, convert backslashes as ${ENV_${var}} +getenv_path(ZZIP_HOME) + + +# construct search paths +set(ZZip_PREFIX_PATH ${ZZIP_HOME} ${ENV_ZZIP_HOME}) +create_search_paths(ZZip) +# redo search if prefix path changed +clear_if_changed(ZZip_PREFIX_PATH + ZZip_LIBRARY_FWK + ZZip_LIBRARY_REL + ZZip_LIBRARY_DBG + ZZip_INCLUDE_DIR +) + +set(ZZip_LIBRARY_NAMES zzip zziplib) +get_debug_names(ZZip_LIBRARY_NAMES) + +use_pkgconfig(ZZip_PKGC zziplib) + +findpkg_framework(ZZip) + +find_path(ZZip_INCLUDE_DIR NAMES zzip/zzip.h HINTS ${ZZip_INC_SEARCH_PATH} ${ZZip_PKGC_INCLUDE_DIRS}) +find_library(ZZip_LIBRARY_REL NAMES ${ZZip_LIBRARY_NAMES} HINTS ${ZZip_LIB_SEARCH_PATH} ${ZZip_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel) +find_library(ZZip_LIBRARY_DBG NAMES ${ZZip_LIBRARY_NAMES_DBG} HINTS ${ZZip_LIB_SEARCH_PATH} ${ZZip_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug) +make_library_set(ZZip_LIBRARY) + +findpkg_finish(ZZip) + From a67cc8e73be69271c474543c86d8dd4fabd6a15f Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 19:02:33 +0100 Subject: [PATCH 03/23] more fixes --- apps/openmw/mwrender/renderingmanager.cpp | 2 +- apps/openmw/mwrender/sky.cpp | 21 +++++++++++---------- apps/openmw/mwrender/sky.hpp | 5 ++--- apps/openmw/mwworld/world.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 95eb8dd33..4f84d90a9 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -51,7 +51,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const cameraPitchNode->attachObject(mRendering.getCamera()); //mSkyManager = 0; - mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera()); + mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment); mPlayer = new MWRender::Player (mRendering.getCamera(), playerNode); mSun = 0; diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index e09fa8a42..343afc13c 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -10,11 +10,14 @@ #include +#include "../mwworld/environment.hpp" +#include "../mwworld/world.hpp" + using namespace MWRender; using namespace Ogre; // the speed at which the clouds are animated -#define CLOUD_SPEED 0.001 +#define CLOUD_SPEED 0.003 // this distance has to be set accordingly so that the // celestial bodies are behind the clouds, but in front of the atmosphere @@ -296,9 +299,10 @@ void SkyManager::ModVertexAlpha(Entity* ent, unsigned int meshType) ent->getMesh()->getSubMesh(0)->vertexData->vertexBufferBinding->getBuffer(ves_diffuse->getSource())->unlock(); } -SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : +SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environment* env) : mGlareFade(0), mGlareEnabled(false) { + mEnvironment = env; mViewport = pCamera->getViewport(); mSceneMgr = pMwRoot->getCreator(); mRootNode = pCamera->getParentSceneNode()->createChildSceneNode(); @@ -312,7 +316,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : Pass* pass = material->getTechnique(0)->getPass(0); pass->setSceneBlending(SBT_TRANSPARENT_ALPHA); mThunderTextureUnit = pass->createTextureUnitState(); - mThunderTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.f, 1.f, 1.f)); // always black colour + mThunderTextureUnit->setColourOperationEx(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, ColourValue(1.f, 1.f, 1.f)); mThunderTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 0.5f); OverlayManager& ovm = OverlayManager::getSingleton(); mThunderOverlay = ovm.create( "ThunderOverlay" ); @@ -504,7 +508,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera) : " uniform float4 emissive \n" ") \n" "{ \n" - " uv += float2(1,1) * time * speed * "<getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", 1); + mCloudMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstantFromTime("time", mEnvironment->mWorld->getTimeScaleFactor()/30.f); /// \todo improve this mMasser->setPhase( static_cast( (int) ((mDay % 32)/4.f)) ); @@ -594,8 +598,8 @@ void SkyManager::update(float duration) mMasser->setVisible(mMasserEnabled); mSecunda->setVisible(mSecundaEnabled); - // rotate the whole sky by 360 degrees every 4 days - mRootNode->roll(Degree(mHourDiff*360/96.f)); + // rotate the stars by 360 degrees every 4 days + mAtmosphereNight->roll(Degree(mEnvironment->mWorld->getTimeScaleFactor()*duration*360 / (3600*96.f))); } void SkyManager::enable() @@ -775,9 +779,6 @@ void SkyManager::setSecundaFade(const float fade) void SkyManager::setHour(double hour) { - mHourDiff = mHour - hour; - if (mHourDiff > 0) mHourDiff -= 24; - mHour = hour; } diff --git a/apps/openmw/mwrender/sky.hpp b/apps/openmw/mwrender/sky.hpp index 2c7b7379a..bf52afd8d 100644 --- a/apps/openmw/mwrender/sky.hpp +++ b/apps/openmw/mwrender/sky.hpp @@ -107,7 +107,7 @@ namespace MWRender class SkyManager { public: - SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera); + SkyManager(Ogre::SceneNode* pMwRoot, Ogre::Camera* pCamera, MWWorld::Environment* env); ~SkyManager(); void update(float duration); @@ -164,12 +164,11 @@ namespace MWRender Ogre::Vector3 getRealSunPos(); private: + MWWorld::Environment* mEnvironment; float mHour; int mDay; int mMonth; - float mHourDiff; - BillboardObject* mSun; BillboardObject* mSunGlare; Moon* mMasser; diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 1c47e3c71..a636ce288 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -478,7 +478,7 @@ namespace MWWorld float World::getTimeScaleFactor() const { - return mGlobalVariables->getInt ("timescale"); + return mGlobalVariables->getFloat ("timescale"); } void World::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) From 7d81422c2753353b5c913aacd6787a054fbb1c84 Mon Sep 17 00:00:00 2001 From: k1ll Date: Fri, 16 Mar 2012 19:17:10 +0100 Subject: [PATCH 04/23] Better fix for the Framework problem. --- cmake/FindOGRE.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 2c07a4d55..78d0ef24e 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -144,7 +144,7 @@ clear_if_changed(OGRE_PREFIX_WATCH ${OGRE_RESET_VARS}) # try to locate Ogre via pkg-config use_pkgconfig(OGRE_PKGC "OGRE${OGRE_LIB_SUFFIX}") -if(NOT OGRE_BUILD_PLATFORM_IPHONE) +if(NOT OGRE_BUILD_PLATFORM_IPHONE AND APPLE) # try to find framework on OSX findpkg_framework(OGRE) else() @@ -258,12 +258,7 @@ if (OGRE_STATIC) endif () endif () - #Removed FWK because it normally is unnecessary and would break the build when not available - #set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} - # ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} - # ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} - # ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) - set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} + set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${OGRE_LIBRARY_FWK} ${ZZip_LIBRARIES} ${ZLIB_LIBRARIES} ${FreeImage_LIBRARIES} ${FREETYPE_LIBRARIES} ${X11_LIBRARIES} ${X11_Xt_LIBRARIES} ${XAW_LIBRARY} ${X11_Xrandr_LIB} ${Cocoa_LIBRARIES} ${Carbon_LIBRARIES}) From 460b584934fb675d667d04aaa3184289385d3cad Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 19:49:01 +0100 Subject: [PATCH 05/23] transition tweaks --- apps/openmw/mwworld/weather.cpp | 148 +++++++++++++++----------------- apps/openmw/mwworld/weather.hpp | 16 ++-- 2 files changed, 77 insertions(+), 87 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index eab1197c5..09d30ee8b 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -22,6 +22,14 @@ const std::string WeatherGlobals::mThunderSoundID1 = "Thunder1"; const std::string WeatherGlobals::mThunderSoundID2 = "Thunder2"; const std::string WeatherGlobals::mThunderSoundID3 = "Thunder3"; +const float WeatherGlobals::mWeatherUpdateTime = 20.f; + +// morrowind sets these per-weather, but since they are only used by 'thunderstorm' +// weather setting anyway, we can just as well set them globally +const float WeatherGlobals::mThunderFrequency = .4; +const float WeatherGlobals::mThunderThreshold = 0.6; +const float WeatherGlobals::mThunderSoundDelay = 0.25; + WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environment* env) : mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0), mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0) @@ -344,7 +352,7 @@ WeatherResult WeatherManager::getResult(const String& weather) { const Weather& current = mWeatherSettings[weather]; WeatherResult result; - + result.mCloudTexture = current.mCloudTexture; result.mCloudBlendFactor = 0; result.mCloudOpacity = current.mCloudsMaximumPercent; @@ -353,16 +361,13 @@ WeatherResult WeatherManager::getResult(const String& weather) result.mGlareView = current.mGlareView; result.mAmbientLoopSoundID = current.mAmbientLoopSoundID; result.mSunColor = current.mSunDiscSunsetColor; - - const float fade_duration = current.mTransitionDelta * 24.f; - - result.mNight = (mHour < 6.f+fade_duration || mHour > 20.f-fade_duration); - + + result.mNight = (mHour < 6 || mHour > 19); + result.mFogDepth = result.mNight ? current.mLandFogNightDepth : current.mLandFogDayDepth; - + // night - if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) - || mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) + if (mHour <= 5.5f || mHour >= 21) { result.mFogColor = current.mFogNightColor; result.mAmbientColor = current.mAmbientNightColor; @@ -370,82 +375,68 @@ WeatherResult WeatherManager::getResult(const String& weather) result.mSkyColor = current.mSkyNightColor; result.mNightFade = 1.f; } - + // sunrise - else if (mHour >= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) && mHour <= WeatherGlobals::mSunriseTime) + else if (mHour >= 5.5f && mHour <= 8) { - if (mHour <= (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)) + if (mHour <= 6) { // fade in - float advance = (WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration+fade_duration)-mHour; - float factor = (advance / fade_duration); + float advance = 6-mHour; + float factor = advance / 0.5f; result.mFogColor = lerp(current.mFogSunriseColor, current.mFogNightColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientNightColor); result.mSunColor = lerp(current.mSunSunriseColor, current.mSunNightColor); result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyNightColor); result.mNightFade = factor; } - else if (mHour >= (WeatherGlobals::mSunriseTime-fade_duration)) + else //if (mHour >= 6) { // fade out - float advance = mHour-(WeatherGlobals::mSunriseTime-fade_duration); - float factor = advance / fade_duration; + float advance = mHour-9; + float factor = advance / 3.f; result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor); result.mSunColor = lerp(current.mSunSunriseColor, current.mSunDayColor); result.mSkyColor = lerp(current.mSkySunriseColor, current.mSkyDayColor); } - else - { - result.mFogColor = current.mFogSunriseColor; - result.mAmbientColor = current.mAmbientSunriseColor; - result.mSunColor = current.mSunSunriseColor; - result.mSkyColor = current.mSkySunriseColor; - } } - + // day - else if (mHour >= (WeatherGlobals::mSunriseTime) && mHour <= (WeatherGlobals::mSunsetTime)) + else if (mHour >= 8 && mHour <= 17) { result.mFogColor = current.mFogDayColor; result.mAmbientColor = current.mAmbientDayColor; result.mSunColor = current.mSunDayColor; result.mSkyColor = current.mSkyDayColor; } - + // sunset - else if (mHour >= (WeatherGlobals::mSunsetTime) && mHour <= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration)) + else if (mHour >= 17 && mHour <= 21) { - if (mHour <= (WeatherGlobals::mSunsetTime+fade_duration)) + if (mHour <= 19) { // fade in - float advance = (WeatherGlobals::mSunsetTime+fade_duration)-mHour; - float factor = (advance / fade_duration); + float advance = 19-mHour; + float factor = (advance / 2); result.mFogColor = lerp(current.mFogSunsetColor, current.mFogDayColor); result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientDayColor); result.mSunColor = lerp(current.mSunSunsetColor, current.mSunDayColor); result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyDayColor); } - else if (mHour >= (WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration)) + else //if (mHour >= 19) { // fade out - float advance = mHour-(WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration-fade_duration); - float factor = advance / fade_duration; + float advance = mHour-19; + float factor = advance / 2.f; result.mFogColor = lerp(current.mFogSunsetColor, current.mFogNightColor); result.mAmbientColor = lerp(current.mAmbientSunsetColor, current.mAmbientNightColor); result.mSunColor = lerp(current.mSunSunsetColor, current.mSunNightColor); result.mSkyColor = lerp(current.mSkySunsetColor, current.mSkyNightColor); result.mNightFade = factor; } - else - { - result.mFogColor = current.mFogSunsetColor; - result.mAmbientColor = current.mAmbientSunsetColor; - result.mSunColor = current.mSunSunsetColor; - result.mSkyColor = current.mSkySunsetColor; - } } - + return result; } @@ -454,16 +445,16 @@ WeatherResult WeatherManager::transition(float factor) const WeatherResult& current = getResult(mCurrentWeather); const WeatherResult& other = getResult(mNextWeather); WeatherResult result; - + result.mCloudTexture = current.mCloudTexture; result.mNextCloudTexture = other.mCloudTexture; result.mCloudBlendFactor = factor; - + result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mFogColor = lerp(current.mFogColor, other.mFogColor); result.mSunColor = lerp(current.mSunColor, other.mSunColor); result.mSkyColor = lerp(current.mSkyColor, other.mSkyColor); - + result.mAmbientColor = lerp(current.mAmbientColor, other.mAmbientColor); result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor); result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth); @@ -471,9 +462,9 @@ WeatherResult WeatherManager::transition(float factor) result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mGlareView = lerp(current.mGlareView, other.mGlareView); - + result.mNight = current.mNight; - + // sound change behaviour: // if 'other' has a new sound, switch to it after 1/2 of the transition length if (other.mAmbientLoopSoundID != "") @@ -481,7 +472,7 @@ WeatherResult WeatherManager::transition(float factor) // if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately else if (current.mAmbientLoopSoundID != "") result.mAmbientLoopSoundID = ""; - + return result; } @@ -490,7 +481,7 @@ void WeatherManager::update(float duration) mWeatherUpdateTime -= duration; bool exterior = (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()); - + if (exterior) { std::string regionstr = mEnvironment->mWorld->getPlayer().getPlayer().getCell()->cell->region; @@ -500,16 +491,16 @@ void WeatherManager::update(float duration) { mCurrentRegion = regionstr; mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*60.f; - + std::string weather; - + if (mRegionOverrides.find(regionstr) != mRegionOverrides.end()) weather = mRegionOverrides[regionstr]; else { // get weather probabilities for the current region const ESM::Region *region = mEnvironment->mWorld->getStore().regions.find (regionstr); - + float clear = region->data.clear/255.f; float cloudy = region->data.cloudy/255.f; float foggy = region->data.foggy/255.f; @@ -520,13 +511,13 @@ void WeatherManager::update(float duration) float blight = region->data.blight/255.f; float snow = region->data.a/255.f; float blizzard = region->data.b/255.f; - + // re-scale to 100 percent const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight+snow+blizzard; - + srand(time(NULL)); float random = ((rand()%100)/100.f) * total; - + if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) weather = "blizzard"; else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) @@ -548,7 +539,7 @@ void WeatherManager::update(float duration) else weather = "clear"; } - + setWeather(weather, false); /* std::cout << "roll result: " << random << std::endl; @@ -560,9 +551,9 @@ void WeatherManager::update(float duration) std::cout << "New weather : " << weather << std::endl; */ } - + WeatherResult result; - + if (mNextWeather != "") { mRemainingTransitionTime -= duration; @@ -572,17 +563,16 @@ void WeatherManager::update(float duration) mNextWeather = ""; } } - + if (mNextWeather != "") result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60))); else result = getResult(mCurrentWeather); mRendering->configureFog(result.mFogDepth, result.mFogColor); - + // disable sun during night - if (mHour >= WeatherGlobals::mSunsetTime+WeatherGlobals::mSunsetDuration - || mHour <= WeatherGlobals::mSunriseTime-WeatherGlobals::mSunriseDuration) + if (mHour >= 21 || mHour <= 5.5f) mRendering->getSkyManager()->sunDisable(); else { @@ -597,7 +587,7 @@ void WeatherManager::update(float duration) mRendering->getSkyManager()->sunEnable(); } - + // moon calculations float night; if (mHour >= 14) @@ -606,9 +596,9 @@ void WeatherManager::update(float duration) night = mHour+10; else night = 0; - + night /= 20.f; - + if (night != 0) { float moonHeight = 1-std::abs((night-0.5)*2); @@ -617,17 +607,17 @@ void WeatherManager::update(float duration) (1-moonHeight)*facing, (1-moonHeight)*facing, moonHeight); - + Vector3 secunda( (1-moonHeight)*facing*0.8, (1-moonHeight)*facing*1.25, moonHeight); - + mRendering->getSkyManager()->setMasserDirection(masser); mRendering->getSkyManager()->setSecundaDirection(secunda); mRendering->getSkyManager()->masserEnable(); mRendering->getSkyManager()->secundaEnable(); - + float hour_fade; if (mHour >= 7.f && mHour <= 14.f) hour_fade = 1-(mHour-7)/3.f; @@ -635,28 +625,28 @@ void WeatherManager::update(float duration) hour_fade = mHour-14; else hour_fade = 1; - + float secunda_angle_fade; float masser_angle_fade; float angle = moonHeight*90.f; - + if (angle >= 30 && angle <= 50) secunda_angle_fade = (angle-30)/20.f; else if (angle <30) secunda_angle_fade = 0.f; else secunda_angle_fade = 1.f; - + if (angle >= 40 && angle <= 50) masser_angle_fade = (angle-40)/10.f; else if (angle <40) masser_angle_fade = 0.f; else masser_angle_fade = 1.f; - + masser_angle_fade *= hour_fade; secunda_angle_fade *= hour_fade; - + mRendering->getSkyManager()->setMasserFade(masser_angle_fade); mRendering->getSkyManager()->setSecundaFade(secunda_angle_fade); } @@ -665,7 +655,7 @@ void WeatherManager::update(float duration) mRendering->getSkyManager()->masserDisable(); mRendering->getSkyManager()->secundaDisable(); } - + if (mCurrentWeather == "thunderstorm" && mNextWeather == "" && exterior) { if (mThunderFlash > 0) @@ -684,7 +674,7 @@ void WeatherManager::update(float duration) mEnvironment->mSoundManager->playSound(soundname, 1.0, 1.0); mThunderSoundDelay = 1000; } - + mThunderFlash -= duration; if (mThunderFlash > 0) mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); @@ -703,20 +693,20 @@ void WeatherManager::update(float duration) if (mThunderChance >= mThunderChanceNeeded) { mThunderFlash = WeatherGlobals::mThunderThreshold; - + mRendering->getSkyManager()->setThunder( mThunderFlash / WeatherGlobals::mThunderThreshold ); - + mThunderSoundDelay = WeatherGlobals::mThunderSoundDelay; } } } else mRendering->getSkyManager()->setThunder(0.f); - + mRendering->setAmbientColour(result.mAmbientColor); mRendering->sunEnable(); mRendering->setSunColour(result.mSunColor); - + mRendering->getSkyManager()->setWeather(result); } else diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index 1828a90c9..b9b40e6fa 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -95,18 +95,18 @@ namespace MWWorld Script Color=255,20,20 */ - static const float mSunriseTime = 8; - static const float mSunsetTime = 18; - static const float mSunriseDuration = 2; - static const float mSunsetDuration = 2; + static const float mSunriseTime; + static const float mSunsetTime; + static const float mSunriseDuration; + static const float mSunsetDuration; - static const float mWeatherUpdateTime = 20.f; + static const float mWeatherUpdateTime; // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally - static const float mThunderFrequency = .4; - static const float mThunderThreshold = 0.6; - static const float mThunderSoundDelay = 0.25; + static const float mThunderFrequency; + static const float mThunderThreshold; + static const float mThunderSoundDelay; static const std::string mThunderSoundID0; static const std::string mThunderSoundID1; static const std::string mThunderSoundID2; From d18b3271b126f92bb3e49ab8041110d1b845ae57 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 20:32:41 +0100 Subject: [PATCH 06/23] transition tweak 2 --- apps/openmw/mwworld/weather.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 09d30ee8b..5ec9fbbcb 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -377,7 +377,7 @@ WeatherResult WeatherManager::getResult(const String& weather) } // sunrise - else if (mHour >= 5.5f && mHour <= 8) + else if (mHour >= 5.5f && mHour <= 9) { if (mHour <= 6) { @@ -393,7 +393,7 @@ WeatherResult WeatherManager::getResult(const String& weather) else //if (mHour >= 6) { // fade out - float advance = mHour-9; + float advance = mHour-6; float factor = advance / 3.f; result.mFogColor = lerp(current.mFogSunriseColor, current.mFogDayColor); result.mAmbientColor = lerp(current.mAmbientSunriseColor, current.mAmbientDayColor); @@ -403,7 +403,7 @@ WeatherResult WeatherManager::getResult(const String& weather) } // day - else if (mHour >= 8 && mHour <= 17) + else if (mHour >= 9 && mHour <= 17) { result.mFogColor = current.mFogDayColor; result.mAmbientColor = current.mAmbientDayColor; From 5ea2122f795c8bef64f2bd58bf05da1dac187e06 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 16 Mar 2012 20:39:58 +0100 Subject: [PATCH 07/23] sun gradually disappears --- apps/openmw/mwrender/sky.cpp | 1 + apps/openmw/mwworld/weather.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 343afc13c..ce61f36b7 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -696,6 +696,7 @@ void SkyManager::setWeather(const MWWorld::WeatherResult& weather) strength = 1.f; mSunGlare->setVisibility(weather.mGlareView * strength); + mSun->setVisibility(strength); mAtmosphereNight->setVisible(weather.mNight && mEnabled); } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 5ec9fbbcb..12a413ccf 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -572,7 +572,7 @@ void WeatherManager::update(float duration) mRendering->configureFog(result.mFogDepth, result.mFogColor); // disable sun during night - if (mHour >= 21 || mHour <= 5.5f) + if (mHour >= 20 || mHour <= 6.f) mRendering->getSkyManager()->sunDisable(); else { From 3ae69f792ada3bbe9c44f2eaa12d1fb11ae1d6b8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 17 Mar 2012 12:57:52 +0100 Subject: [PATCH 08/23] no light-"jumps" during night --- apps/openmw/mwworld/weather.cpp | 56 +++++++++++---------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 12a413ccf..a5c954ef8 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -465,14 +465,6 @@ WeatherResult WeatherManager::transition(float factor) result.mNight = current.mNight; - // sound change behaviour: - // if 'other' has a new sound, switch to it after 1/2 of the transition length - if (other.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = factor>0.5 ? other.mAmbientLoopSoundID : current.mAmbientLoopSoundID; - // if 'current' has a sound and 'other' does not have a sound, turn off the sound immediately - else if (current.mAmbientLoopSoundID != "") - result.mAmbientLoopSoundID = ""; - return result; } @@ -541,15 +533,6 @@ void WeatherManager::update(float duration) } setWeather(weather, false); - /* - std::cout << "roll result: " << random << std::endl; - - std::cout << regionstr << " weather probabilities: " << clear << " " << cloudy << " " << foggy << " " - << overcast << " " << rain << " " << thunder << " " << ash << " " << blight << " " << snow << " " - << blizzard << std::endl; - - std::cout << "New weather : " << weather << std::endl; - */ } WeatherResult result; @@ -575,18 +558,26 @@ void WeatherManager::update(float duration) if (mHour >= 20 || mHour <= 6.f) mRendering->getSkyManager()->sunDisable(); else - { - // during day, calculate sun angle - float height = 1-std::abs(((mHour-13)/7.f)); - int facing = mHour > 13.f ? 1 : -1; - Vector3 final( - (1-height)*facing, - (1-height)*facing, - height); - mRendering->setSunDirection(final); - mRendering->getSkyManager()->sunEnable(); - } + + // sun angle + float height; + + // rise at 6, set at 20 + if (mHour >= 6 && mHour <= 20) + height = 1-std::abs(((mHour-13)/7.f)); + else if (mHour > 20) + height = (mHour-20.f)/4.f; + else //if (mHour > 0 && mHour < 6) + height = 1-(mHour/6.f); + + int facing = (mHour > 13.f) ? 1 : -1; + + Vector3 final( + (1-height)*facing, + (1-height)*facing, + height); + mRendering->setSunDirection(final); // moon calculations float night; @@ -755,15 +746,6 @@ void WeatherManager::update(float duration) void WeatherManager::setHour(const float hour) { - // accelerate a bit for testing - /* - mHour += 0.005; - - if (mHour >= 24.f) mHour = 0.f; - - std::cout << "hour " << mHour << std::endl; - */ - mHour = hour; } From 18404011722c5dbda1b401ab6c043c9e50b2bf6f Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 17 Mar 2012 13:14:31 +0100 Subject: [PATCH 09/23] weather transitions (e.g. from clear to cloudy) use timescale --- apps/openmw/mwworld/weather.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index a5c954ef8..ccbca52db 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -328,6 +328,9 @@ WeatherManager::WeatherManager(MWRender::RenderingManager* rendering, Environmen void WeatherManager::setWeather(const String& weather, bool instant) { + if (weather == mCurrentWeather && mNextWeather == "") + return; + if (instant || mFirstUpdate) { mNextWeather = ""; @@ -339,12 +342,12 @@ void WeatherManager::setWeather(const String& weather, bool instant) if (mNextWeather != "") { // transition more than 50% finished? - if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60) <= 0.5) + if (mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600) <= 0.5) mCurrentWeather = mNextWeather; } - + mNextWeather = weather; - mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60; + mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600; } } @@ -459,7 +462,8 @@ WeatherResult WeatherManager::transition(float factor) result.mSunDiscColor = lerp(current.mSunDiscColor, other.mSunDiscColor); result.mFogDepth = lerp(current.mFogDepth, other.mFogDepth); result.mWindSpeed = lerp(current.mWindSpeed, other.mWindSpeed); - result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); + //result.mCloudSpeed = lerp(current.mCloudSpeed, other.mCloudSpeed); + result.mCloudSpeed = current.mCloudSpeed; result.mCloudOpacity = lerp(current.mCloudOpacity, other.mCloudOpacity); result.mGlareView = lerp(current.mGlareView, other.mGlareView); @@ -470,7 +474,7 @@ WeatherResult WeatherManager::transition(float factor) void WeatherManager::update(float duration) { - mWeatherUpdateTime -= duration; + mWeatherUpdateTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); bool exterior = (mEnvironment->mWorld->isCellExterior() || mEnvironment->mWorld->isCellQuasiExterior()); @@ -482,7 +486,7 @@ void WeatherManager::update(float duration) if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) { mCurrentRegion = regionstr; - mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*60.f; + mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*3600; std::string weather; @@ -539,7 +543,7 @@ void WeatherManager::update(float duration) if (mNextWeather != "") { - mRemainingTransitionTime -= duration; + mRemainingTransitionTime -= duration * mEnvironment->mWorld->getTimeScaleFactor(); if (mRemainingTransitionTime < 0) { mCurrentWeather = mNextWeather; @@ -548,10 +552,10 @@ void WeatherManager::update(float duration) } if (mNextWeather != "") - result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*60))); + result = transition(1-(mRemainingTransitionTime/(mWeatherSettings[mCurrentWeather].mTransitionDelta*24.f*3600))); else result = getResult(mCurrentWeather); - + mRendering->configureFog(result.mFogDepth, result.mFogColor); // disable sun during night @@ -570,9 +574,9 @@ void WeatherManager::update(float duration) height = (mHour-20.f)/4.f; else //if (mHour > 0 && mHour < 6) height = 1-(mHour/6.f); - + int facing = (mHour > 13.f) ? 1 : -1; - + Vector3 final( (1-height)*facing, (1-height)*facing, From dbbf50a184ccad123387a7864cc35dcb01f200b6 Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Sat, 17 Mar 2012 15:52:57 +0200 Subject: [PATCH 10/23] Journal sounds, close sound will be added later --- apps/openmw/mwgui/journalwindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 3f3c89f39..5c9ef1f9b 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -4,6 +4,8 @@ #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwsound/soundmanager.hpp" + namespace { struct book @@ -115,6 +117,8 @@ MWGui::JournalWindow::JournalWindow (WindowManager& parWindowManager) void MWGui::JournalWindow::open() { mPageNumber = 0; + std::string journalOpenSound = "book open"; + mWindowManager.getEnvironment().mSoundManager->playSound (journalOpenSound, 1.0, 1.0); if(mWindowManager.getEnvironment().mJournal->begin()!=mWindowManager.getEnvironment().mJournal->end()) { book journal; @@ -176,6 +180,8 @@ void MWGui::JournalWindow::notifyNextPage(MyGUI::WidgetPtr _sender) { if(mPageNumber < int(leftPages.size())-1) { + std::string nextSound = "book page2"; + mWindowManager.getEnvironment().mSoundManager->playSound (nextSound, 1.0, 1.0); mPageNumber = mPageNumber + 1; displayLeftText(leftPages[mPageNumber]); displayRightText(rightPages[mPageNumber]); @@ -186,6 +192,8 @@ void MWGui::JournalWindow::notifyPrevPage(MyGUI::WidgetPtr _sender) { if(mPageNumber > 0) { + std::string prevSound = "book page"; + mWindowManager.getEnvironment().mSoundManager->playSound (prevSound, 1.0, 1.0); mPageNumber = mPageNumber - 1; displayLeftText(leftPages[mPageNumber]); displayRightText(rightPages[mPageNumber]); From b83b7d0650cdd77a8da0568cd70c4ed4de64470a Mon Sep 17 00:00:00 2001 From: k1ll Date: Sat, 17 Mar 2012 20:03:37 +0100 Subject: [PATCH 11/23] Added OGRE_STATIC as cmake option and removed the code for the BSPSceneManager plugin. --- CMakeLists.txt | 2 ++ libs/openengine/ogre/renderer.cpp | 6 +----- libs/openengine/ogre/renderer.hpp | 6 ------ 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfa6dd8b0..e5256aa7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,8 @@ set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VE configure_file ("${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp.cmake" "${OpenMW_SOURCE_DIR}/Docs/mainpage.hpp") +option(OGRE_STATIC "Link static build of Ogre and Ogre Plugins into the binaries" FALSE) + # Sound source selection option(USE_AUDIERE "use Audiere for sound" OFF) option(USE_FFMPEG "use ffmpeg for sound" OFF) diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index f2a23c831..4ded3343f 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -48,10 +48,6 @@ bool OgreRenderer::loadPlugins() mParticleFXPlugin = new Ogre::ParticleFXPlugin(); mRoot->installPlugin(mParticleFXPlugin); #endif - #ifdef ENABLE_PLUGIN_BSPSceneManager - mBSPPlugin = new Ogre::BspSceneManagerPlugin(); - mRoot->installPlugin(mBSPPlugin); - #endif return true; } @@ -88,7 +84,7 @@ bool OgreRenderer::configure(bool showConfig, // Disable logging log->setDebugOutputEnabled(false); -#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) || defined(ENABLE_PLUGIN_BSPSceneManager) +#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) mRoot = new Root("", cfgPath, ""); loadPlugins(); #else diff --git a/libs/openengine/ogre/renderer.hpp b/libs/openengine/ogre/renderer.hpp index fa7435501..6516b0a80 100644 --- a/libs/openengine/ogre/renderer.hpp +++ b/libs/openengine/ogre/renderer.hpp @@ -17,9 +17,6 @@ #ifdef ENABLE_PLUGIN_ParticleFX # include "OgreParticleFXPlugin.h" #endif -#ifdef ENABLE_PLUGIN_BSPSceneManager -# include "OgreBspSceneManagerPlugin.h" -#endif #ifdef ENABLE_PLUGIN_GL # include "OgreGLPlugin.h" #endif @@ -56,9 +53,6 @@ namespace Render #ifdef ENABLE_PLUGIN_ParticleFX Ogre::ParticleFXPlugin* mParticleFXPlugin; #endif - #ifdef ENABLE_PLUGIN_BSPSceneManager - Ogre::BspSceneManagerPlugin* mBSPPlugin; - #endif #ifdef ENABLE_PLUGIN_GL Ogre::GLPlugin* mGLPlugin; #endif From af875896ad843d42a40cc4be59c233f1c661fd64 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 11:09:38 +0100 Subject: [PATCH 12/23] fix for issue #179 --- apps/openmw/engine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 0e2189307..fcdd0bf99 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -411,6 +411,9 @@ void OMW::Engine::go() void OMW::Engine::activate() { + if (mEnvironment.mWindowManager->getMode()!=MWGui::GM_Game) + return; + std::string handle = mEnvironment.mWorld->getFacedHandle(); if (handle.empty()) From c2329b7027b6180913cce9fe148a85e13daab075 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 18 Mar 2012 20:32:50 +0100 Subject: [PATCH 13/23] removed preprocessor constants --- apps/openmw/mwrender/sky.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index ce61f36b7..a747b9be0 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -16,13 +16,6 @@ using namespace MWRender; using namespace Ogre; -// the speed at which the clouds are animated -#define CLOUD_SPEED 0.003 - -// this distance has to be set accordingly so that the -// celestial bodies are behind the clouds, but in front of the atmosphere -#define CELESTIAL_BODY_DISTANCE 1000.f - BillboardObject::BillboardObject( const String& textureName, const float initialSize, const Vector3& position, @@ -53,7 +46,7 @@ void BillboardObject::setVisibility(const float visibility) void BillboardObject::setPosition(const Vector3& pPosition) { Vector3 normalised = pPosition.normalisedCopy(); - Vector3 finalPosition = normalised * CELESTIAL_BODY_DISTANCE; + Vector3 finalPosition = normalised * 1000.f; mBBSet->setCommonDirection( -normalised ); @@ -88,7 +81,7 @@ void BillboardObject::init(const String& textureName, { SceneManager* sceneMgr = rootNode->getCreator(); - Vector3 finalPosition = position.normalisedCopy() * CELESTIAL_BODY_DISTANCE; + Vector3 finalPosition = position.normalisedCopy() * 1000.f; static unsigned int bodyCount=0; @@ -508,7 +501,7 @@ SkyManager::SkyManager (SceneNode* pMwRoot, Camera* pCamera, MWWorld::Environmen " uniform float4 emissive \n" ") \n" "{ \n" - " uv += float2(1,0) * time * speed * "< Date: Sun, 18 Mar 2012 22:38:53 +0200 Subject: [PATCH 14/23] Fix for the --nosound crash --- apps/openmw/mwsound/soundmanager.cpp | 8 ++++++-- apps/openmw/mwsound/soundmanager.hpp | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index a5ba04e26..6a2ba2fe4 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -67,6 +67,7 @@ namespace MWSound , updater(mgr) , cameraTracker(mgr) , mCurrentPlaylist(NULL) + , mUsingSound(useSound) { if(useSound) { @@ -105,8 +106,11 @@ namespace MWSound SoundManager::~SoundManager() { - Ogre::Root::getSingleton().removeFrameListener(&updater); - cameraTracker.unfollowCamera(); + if(mUsingSound) + { + Ogre::Root::getSingleton().removeFrameListener(&updater); + cameraTracker.unfollowCamera(); + } } // Convert a soundId to file name, and modify the volume diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index bd3b67679..dcf64b90c 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -82,6 +82,8 @@ namespace MWSound IDMap mLoopedSounds; + bool mUsingSound; + std::string lookup(const std::string &soundId, float &volume, float &min, float &max); void add(const std::string &file, From d10b18b0f305b1a6117c6b6e2f72b0c5b5e3c68d Mon Sep 17 00:00:00 2001 From: Michael Papageorgiou Date: Sun, 18 Mar 2012 22:50:52 +0200 Subject: [PATCH 15/23] Removed a couple of warnings with nosound --- apps/openmw/mwsound/soundmanager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 6a2ba2fe4..226796603 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -358,6 +358,9 @@ namespace MWSound void SoundManager::playPlaylist(std::string playlist) { + if (!mUsingSound) + return; + if (playlist == "") { if(!isMusicPlaying()) @@ -379,6 +382,9 @@ namespace MWSound void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename) { + if (!mUsingSound) + return; + // The range values are not tested std::string filePath = Files::FileListLocator(mSoundFiles, filename, mFSStrict, true); if(!filePath.empty()) From cab869824a6b4a32e1c426dbbb633a226aaf4eda Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 22:18:09 +0100 Subject: [PATCH 16/23] bumping version number --- CMakeLists.txt | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a12126c2a..d2cb1e0e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 12) +set (OPENMW_VERSION_MINOR 13) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") diff --git a/readme.txt b/readme.txt index 88c170088..c61d835cb 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.12.0 +Version: 0.13.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org From 16e61bb0285cbd6072b1afae9da473ec6ba49722 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 22:20:45 +0100 Subject: [PATCH 17/23] updated developer list in readme file --- readme.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index c61d835cb..2f63e8174 100644 --- a/readme.txt +++ b/readme.txt @@ -96,9 +96,12 @@ athile Cris “Mirceam” Mihalache gugus / gus Jacob “Yacoby” Essex +Jannik “scrawl” Heller Jason “jhooks” Hooks +Karl-Felix “k1ll” Glatzer Lukasz “lgro” Gromanowski Marc “Zini” Zinnschlag +Michael “werdanith” Papageorgiou Nikolay “corristo” Kasyanov Pieter “pvdk” van der Kloet Sebastian “swick” Wick @@ -110,7 +113,6 @@ Diggory Hardy Jan Borsodi Jan-Peter “peppe” Nilsson Josua Grawitter -Karl-Felix “k1ll” Glatzer Nicolay Korslund sergoz Star-Demon From c874fff4b16f69801c13ae877f2e89735d4f6a27 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 18 Mar 2012 22:25:43 +0100 Subject: [PATCH 18/23] added 0.13.0 changelog --- readme.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/readme.txt b/readme.txt index 2f63e8174..149fd4f19 100644 --- a/readme.txt +++ b/readme.txt @@ -127,6 +127,36 @@ Thanks to Kevin Ryan for kindly providing us with the icon used for the Data Fil CHANGELOG +0.13.0 + +Bug #145: Fixed sound problems after cell change +Bug #179: Pressing space in console triggers activation +Bug #186: CMake doesn't use the debug versions of Ogre libraries on Linux +Bug #189: ASCII 16 character added to console on it's activation on Mac OS X +Bug #190: Case Folding fails with music files +Bug #196: Collision shapes out of place +Bug #202: ESMTool doesn't not work with localised ESM files anymore +Bug #203: Torch lights only visible on short distance +Bug #207: Ogre.log not written +Bug #209: Sounds do not play +Bug #210: Ogre crash at Dren plantation +Feature #9: NPC Dialogue Window +Feature #16/42: New sky/weather implementation +Feature #40: Fading +Feature #48: NPC Dialogue System +Feature #117: Equipping Items (backend only, no GUI yet, no rendering of equipped items yet) +Feature #161: Load REC_PGRD records +Feature #195: Wireframe-mode +Feature #198/199: Various sound effects +Feature #206: Allow picking data path from launcher if non is set +Task #108: Refactor window manager class +Task #172: Sound Manager Cleanup +Task #173: Create OpenEngine systems in the appropriate manager classes +Task #184: Adjust MSVC and gcc warning levels +Task #185: RefData rewrite +Task #201: Workaround for transparency issues +Task #208: silenced esm_reader.hpp warning + 0.12.0 Bug #154: FPS Drop From 1f76f375312f8c015f74e7de7603e841bbe161c7 Mon Sep 17 00:00:00 2001 From: k1ll Date: Mon, 19 Mar 2012 14:25:33 +0100 Subject: [PATCH 19/23] Adds search for plugins in OGRE dirs with version suffix and a workaround for a strange problem with set to FindOgre.cmake. --- cmake/FindOGRE.cmake | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 78d0ef24e..5e6453eea 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -405,8 +405,16 @@ macro(ogre_find_plugin PLUGIN HEADER) set(OGRE_${PLUGIN}_LIBRARY_NAMES "${PLUGIN}${OGRE_LIB_SUFFIX}") get_debug_names(OGRE_${PLUGIN}_LIBRARY_NAMES) set(OGRE_${PLUGIN}_LIBRARY_FWK ${OGRE_LIBRARY_FWK}) + # Search for release plugins in OGRE dir with version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + # Search for release plugins in OGRE dir without version suffix find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + # Search for debug plugins in OGRE dir with version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt debug debug/opt) + # Search for debug plugins in OGRE dir without version suffix find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt) make_library_set(OGRE_${PLUGIN}_LIBRARY) @@ -441,9 +449,13 @@ macro(ogre_find_plugin PLUGIN HEADER) PATH_SUFFIXES "" bin bin/debug debug) elseif (UNIX) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_REL} PATH) - set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)") + # For some reason this fails + #set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (release)") + set(OGRE_PLUGIN_DIR_REL ${OGRE_PLUGIN_DIR_TMP}) get_filename_component(OGRE_PLUGIN_DIR_TMP ${OGRE_${PLUGIN}_LIBRARY_DBG} PATH) - set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)") + # Same here + #set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP} CACHE STRING "Ogre plugin dir (debug)") + set(OGRE_PLUGIN_DIR_DBG ${OGRE_PLUGIN_DIR_TMP}) endif () endif () From 5abaf1fee24d68830f3f57f1182f09acd07882d5 Mon Sep 17 00:00:00 2001 From: k1ll Date: Mon, 19 Mar 2012 15:04:55 +0100 Subject: [PATCH 20/23] Check if searching OGRE dir with version suffix failed. I'm not sure if this is the right way to do it though. --- cmake/FindOGRE.cmake | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmake/FindOGRE.cmake b/cmake/FindOGRE.cmake index 5e6453eea..fb4a090c6 100644 --- a/cmake/FindOGRE.cmake +++ b/cmake/FindOGRE.cmake @@ -408,15 +408,19 @@ macro(ogre_find_plugin PLUGIN HEADER) # Search for release plugins in OGRE dir with version suffix find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) - # Search for release plugins in OGRE dir without version suffix - find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} - HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + if(NOT EXISTS "${OGRE_${PLUGIN}_LIBRARY_REL}") + # Search for release plugins in OGRE dir without version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_REL NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt release release/opt relwithdebinfo relwithdebinfo/opt minsizerel minsizerel/opt) + endif() # Search for debug plugins in OGRE dir with version suffix find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE-${OGRE_VERSION} opt debug debug/opt) - # Search for debug plugins in OGRE dir without version suffix - find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} - HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt) + if(NOT EXISTS "${OGRE_${PLUGIN}_LIBRARY_DBG}") + # Search for debug plugins in OGRE dir without version suffix + find_library(OGRE_${PLUGIN}_LIBRARY_DBG NAMES ${OGRE_${PLUGIN}_LIBRARY_NAMES_DBG} + HINTS ${OGRE_LIBRARY_DIRS} PATH_SUFFIXES "" OGRE opt debug debug/opt) + endif() make_library_set(OGRE_${PLUGIN}_LIBRARY) if (OGRE_${PLUGIN}_LIBRARY OR OGRE_${PLUGIN}_INCLUDE_DIR) From ba4d44eb67bf9900aa7053118e4e478600fac96a Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 18:01:41 +0100 Subject: [PATCH 21/23] fix for questions. --- apps/openmw/mwdialogue/dialoguemanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 34cd51f25..81a89761a 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -550,7 +550,6 @@ namespace MWDialogue void DialogueManager::parseText(std::string text) { - std::cout << "PARSE"; std::list::iterator it; for(it = actorKnownTopics.begin();it != actorKnownTopics.end();it++) { @@ -786,8 +785,9 @@ namespace MWDialogue if(found) { for (std::vector::const_iterator iter2 = iter; - iter2!=ndialogue.mInfo.begin(); --iter2) + iter2!=ndialogue.mInfo.begin();) { + --iter2; if (isMatching (mActor, *iter2) && functionFilter(mActor,*iter2,true)) { mChoiceMap.clear(); From 11569819dbda574e0452565a514fff5c85e5450c Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 18:01:54 +0100 Subject: [PATCH 22/23] compilation fix --- apps/openmw/mwworld/weather.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 47f436191..044d6e83a 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -26,11 +26,7 @@ const float WeatherGlobals::mSunsetTime = 18; const float WeatherGlobals::mSunriseDuration = 2; const float WeatherGlobals::mSunsetDuration = 2; const float WeatherGlobals::mWeatherUpdateTime = 20.f; -const float WeatherGlobals::mThunderFrequency = .4; -const float WeatherGlobals::mThunderThreshold = 0.6; -const float WeatherGlobals::mThunderSoundDelay = 0.25; -const float WeatherGlobals::mWeatherUpdateTime = 20.f; // morrowind sets these per-weather, but since they are only used by 'thunderstorm' // weather setting anyway, we can just as well set them globally From 270739153585a1f377d4be79e7db0ea0a4706596 Mon Sep 17 00:00:00 2001 From: gugus Date: Mon, 19 Mar 2012 18:30:52 +0100 Subject: [PATCH 23/23] fix for questions --- apps/openmw/mwdialogue/dialoguemanager.cpp | 34 +++++++--------------- apps/openmw/mwgui/dialogue.cpp | 8 ++--- apps/openmw/mwgui/dialogue.hpp | 2 +- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanager.cpp b/apps/openmw/mwdialogue/dialoguemanager.cpp index 81a89761a..7950a7888 100644 --- a/apps/openmw/mwdialogue/dialoguemanager.cpp +++ b/apps/openmw/mwdialogue/dialoguemanager.cpp @@ -560,16 +560,14 @@ namespace MWDialogue if(pos==0) { knownTopics[*it] = true; - win->addKeyword(*it); } else if(text.substr(pos -1,1) == " ") { knownTopics[*it] = true; - win->addKeyword(*it); } } - } + updateTopics(); } void DialogueManager::startDialogue (const MWWorld::Ptr& actor) @@ -692,6 +690,8 @@ namespace MWDialogue void DialogueManager::updateTopics() { + std::list keywordList; + actorKnownTopics.clear(); MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; @@ -709,12 +709,14 @@ namespace MWDialogue //does the player know the topic? if(knownTopics.find(toLower(it->first)) != knownTopics.end()) { - win->addKeyword(it->first); + keywordList.push_back(it->first); + break; } } } } } + win->setKeywords(keywordList); } void DialogueManager::keywordSelected(std::string keyword) @@ -765,41 +767,27 @@ namespace MWDialogue { mChoice = mChoiceMap[answere]; - //ESMS::RecListT::MapType dialogueList = mEnvironment.mWorld->getStore().dialogs.list; - bool found = false; - //ESMS::RecListT::MapType::iterator it; std::vector::const_iterator iter; - //for(it = dialogueList.begin(); it!=dialogueList.end();it++) if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) { ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; if(ndialogue.type == ESM::Dialogue::Topic) { - for (iter = ndialogue.mInfo.begin(); + for (std::vector::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { - if(iter->id == mLastDialogue.id) found = true; - if(found) break; - } - } - if(found) - { - for (std::vector::const_iterator iter2 = iter; - iter2!=ndialogue.mInfo.begin();) - { - --iter2; - if (isMatching (mActor, *iter2) && functionFilter(mActor,*iter2,true)) + if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { mChoiceMap.clear(); mChoice = -1; mIsInChoice = false; MWGui::DialogueWindow* win = mEnvironment.mWindowManager->getDialogueWindow(); - std::string text = iter2->response; + std::string text = iter->response; parseText(text); win->addText(text); - executeScript(iter2->resultScript); + executeScript(iter->resultScript); mLastTopic = mLastTopic; - mLastDialogue = *iter2; + mLastDialogue = *iter; break; } } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 549022e70..5ab860443 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -113,12 +113,12 @@ void DialogueWindow::startDialogue(std::string npcName) setText("NpcName", npcName); } -void DialogueWindow::addKeyword(std::string keyWord) +void DialogueWindow::setKeywords(std::list keyWords) { - if(topicsList->findItemIndexWith(keyWord) == MyGUI::ITEM_NONE) + topicsList->removeAllItems(); + for(std::list::iterator it = keyWords.begin(); it != keyWords.end(); it++) { - topicsList->addItem(keyWord); - pTopicsText[keyWord] = " "; + topicsList->addItem(*it); } } diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 4520d4586..7dfd7bb7f 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -42,7 +42,7 @@ namespace MWGui void startDialogue(std::string npcName); void stopDialogue(); - void addKeyword(std::string keyWord); + void setKeywords(std::list keyWord); void removeKeyword(std::string keyWord); void addText(std::string text); void addTitle(std::string text);