refdata change

This commit is contained in:
Jason Hooks 2011-11-08 22:59:39 -05:00
commit c25b49d2b6
40 changed files with 212 additions and 254 deletions

View file

@ -82,168 +82,6 @@ ELSE()
message (STATUS "OpenMW pre-built binaries not found. Using standard locations.") message (STATUS "OpenMW pre-built binaries not found. Using standard locations.")
ENDIF() ENDIF()
# source directory: components
set(COMP_DIR ${CMAKE_SOURCE_DIR}/components)
set(BSA
${COMP_DIR}/bsa/bsa_archive.cpp
${COMP_DIR}/bsa/bsa_file.cpp)
set(BSA_HEADER
${COMP_DIR}/bsa/bsa_archive.hpp
${COMP_DIR}/bsa/bsa_file.hpp)
source_group(components\\bsa FILES ${BSA} ${BSA_HEADER})
set(CFG
${COMP_DIR}/cfg/configurationmanager.cpp
)
set(CFG_HEADER
${COMP_DIR}/cfg/configurationmanager.hpp
)
source_group(components\\cfg FILES ${CFG} ${CFG_HEADER})
set(NIF
${COMP_DIR}/nif/nif_file.cpp)
set(NIF_HEADER
${COMP_DIR}/nif/controlled.hpp
${COMP_DIR}/nif/effect.hpp
${COMP_DIR}/nif/nif_types.hpp
${COMP_DIR}/nif/record.hpp
${COMP_DIR}/nif/controller.hpp
${COMP_DIR}/nif/extra.hpp
${COMP_DIR}/nif/node.hpp
${COMP_DIR}/nif/record_ptr.hpp
${COMP_DIR}/nif/data.hpp
${COMP_DIR}/nif/nif_file.hpp
${COMP_DIR}/nif/property.hpp)
source_group(components\\nif FILES ${NIF} ${NIF_HEADER})
set(NIFOGRE
${COMP_DIR}/nifogre/ogre_nif_loader.cpp)
set(NIFOGRE_HEADER
${COMP_DIR}/nifogre/ogre_nif_loader.hpp)
source_group(components\\nifogre FILES ${NIFOGRE} ${NIFOGRE_HEADER})
set(NIFBULLET
${COMP_DIR}/nifbullet/bullet_nif_loader.cpp)
set(NIFBULLET_HEADER
${COMP_DIR}/nifbullet/bullet_nif_loader.hpp)
source_group(components\\nifbullet FILES ${NIFBULLET} ${NIFBULLET_HEADER})
set(TO_UTF8
${COMP_DIR}/to_utf8/to_utf8.cpp)
set(TO_UTF8_HEADER
${COMP_DIR}/to_utf8/to_utf8.hpp)
source_group(components\\to_utf8 FILES ${TO_UTF8} ${TO_UTF8_HEADER})
set(FILE_FINDER
${COMP_DIR}/file_finder/search.cpp)
set(FILE_FINDER_HEADER
${COMP_DIR}/file_finder/file_finder.hpp
${COMP_DIR}/file_finder/filename_less.hpp
${COMP_DIR}/file_finder/search.hpp)
source_group(components\\file_finder FILES ${FILE_FINDER} ${FILE_FINDER_HEADER})
set(ESM_STORE
${COMP_DIR}/esm_store/store.cpp)
set(ESM_STORE_HEADER
${COMP_DIR}/esm_store/cell_store.hpp
${COMP_DIR}/esm_store/reclists.hpp
${COMP_DIR}/esm_store/store.hpp)
source_group(components\\esm_store FILES ${ESM_STORE} ${ESM_STORE_HEADER})
file(GLOB ESM_HEADER ${COMP_DIR}/esm/*.hpp)
set(ESM
${COMP_DIR}/esm/attr.cpp
${COMP_DIR}/esm/esm_reader.cpp
${COMP_DIR}/esm/loadland.cpp
${COMP_DIR}/esm/loadacti.cpp
${COMP_DIR}/esm/loadalch.cpp
${COMP_DIR}/esm/loadappa.cpp
${COMP_DIR}/esm/loadarmo.cpp
${COMP_DIR}/esm/loadbody.cpp
${COMP_DIR}/esm/loadbook.cpp
${COMP_DIR}/esm/loadbsgn.cpp
${COMP_DIR}/esm/loadcell.cpp
${COMP_DIR}/esm/loadclas.cpp
${COMP_DIR}/esm/loadclot.cpp
${COMP_DIR}/esm/loadcont.cpp
${COMP_DIR}/esm/loadcrea.cpp
${COMP_DIR}/esm/loaddial.cpp
${COMP_DIR}/esm/loaddoor.cpp
${COMP_DIR}/esm/loadench.cpp
${COMP_DIR}/esm/loadfact.cpp
${COMP_DIR}/esm/loadglob.cpp
${COMP_DIR}/esm/loadgmst.cpp
${COMP_DIR}/esm/loadinfo.cpp
${COMP_DIR}/esm/loadingr.cpp
${COMP_DIR}/esm/loadlevlist.cpp
${COMP_DIR}/esm/loadligh.cpp
${COMP_DIR}/esm/loadlocks.cpp
${COMP_DIR}/esm/loadltex.cpp
${COMP_DIR}/esm/loadmgef.cpp
${COMP_DIR}/esm/loadmisc.cpp
${COMP_DIR}/esm/loadnpc.cpp
${COMP_DIR}/esm/loadpgrd.cpp
${COMP_DIR}/esm/loadrace.cpp
${COMP_DIR}/esm/loadregn.cpp
${COMP_DIR}/esm/loadscpt.cpp
${COMP_DIR}/esm/loadskil.cpp
${COMP_DIR}/esm/loadsndg.cpp
${COMP_DIR}/esm/loadsoun.cpp
${COMP_DIR}/esm/loadspel.cpp
${COMP_DIR}/esm/loadsscr.cpp
${COMP_DIR}/esm/loadstat.cpp
${COMP_DIR}/esm/loadweap.cpp
)
source_group(components\\esm FILES ${ESM_HEADER} ${ESM})
set(MISC
${COMP_DIR}/misc/stringops.cpp
)
set(MISC_HEADER
${COMP_DIR}/misc/slice_array.hpp
${COMP_DIR}/misc/stringops.hpp
)
source_group(components\\misc FILES ${MISC} ${MISC_HEADER})
set(FILES
${COMP_DIR}/files/linuxpath.cpp
${COMP_DIR}/files/windowspath.cpp
${COMP_DIR}/files/macospath.cpp
${COMP_DIR}/files/multidircollection.cpp
${COMP_DIR}/files/collections.cpp
${COMP_DIR}/files/fileops.cpp
)
set(FILES_HEADER
${COMP_DIR}/files/linuxpath.hpp
${COMP_DIR}/files/windowspath.hpp
${COMP_DIR}/files/macospath.hpp
${COMP_DIR}/files/path.hpp
${COMP_DIR}/files/multidircollection.hpp
${COMP_DIR}/files/collections.hpp
${COMP_DIR}/files/fileops.hpp
)
source_group(components\\files FILES ${FILES} ${FILES_HEADER})
file(GLOB COMPILER ${COMP_DIR}/compiler/*.cpp)
file(GLOB COMPILER_HEADER ${COMP_DIR}/compiler/*.hpp)
source_group(components\\compiler FILES ${COMPILER} ${COMPILER_HEADER})
file(GLOB INTERPRETER ${COMP_DIR}/interpreter/*.cpp)
file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp)
source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER})
set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8}
${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET} ${FILES}
${CFG}
)
set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER}
${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER}
${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER} ${FILES_HEADER}
${CFG_HEADER}
)
# source directory: libs # source directory: libs
set(LIBDIR ${CMAKE_SOURCE_DIR}/libs) set(LIBDIR ${CMAKE_SOURCE_DIR}/libs)
@ -513,6 +351,9 @@ if(DPKG_PROGRAM)
include(CPack) include(CPack)
endif(DPKG_PROGRAM) endif(DPKG_PROGRAM)
# Components
add_subdirectory (components)
# Apps and tools # Apps and tools
add_subdirectory( apps/openmw ) add_subdirectory( apps/openmw )

View file

@ -8,13 +8,11 @@ source_group(apps\\esmtool FILES ${ESMTOOL})
# Main executable # Main executable
add_executable(esmtool add_executable(esmtool
${ESMTOOL} ${ESMTOOL}
${MISC} ${MISC_HEADER}
${TO_UTF8}
${ESM}
) )
target_link_libraries(esmtool target_link_libraries(esmtool
${Boost_LIBRARIES} ${Boost_LIBRARIES}
components
) )
#if (APPLE) #if (APPLE)

View file

@ -8,6 +8,8 @@ set(LAUNCHER
playpage.cpp playpage.cpp
pluginsmodel.cpp pluginsmodel.cpp
pluginsview.cpp pluginsview.cpp
launcher.rc
) )
set(LAUNCHER_HEADER set(LAUNCHER_HEADER
@ -50,11 +52,6 @@ include(${QT_USE_FILE})
# Main executable # Main executable
add_executable(omwlauncher add_executable(omwlauncher
${LAUNCHER} ${LAUNCHER}
${MISC} ${MISC_HEADER}
${FILES} ${FILES_HEADER}
${CFG} ${CFG_HEADER}
${TO_UTF8}
${ESM}
${RCC_SRCS} ${RCC_SRCS}
${MOC_SRCS} ${MOC_SRCS}
) )
@ -64,6 +61,7 @@ target_link_libraries(omwlauncher
${OGRE_LIBRARIES} ${OGRE_LIBRARIES}
${QT_LIBRARIES} ${QT_LIBRARIES}
${PNG_LIBRARY} ${PNG_LIBRARY}
components
) )
if(DPKG_PROGRAM) if(DPKG_PROGRAM)
@ -78,7 +76,7 @@ if (APPLE)
else() else()
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss")
configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg") "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg")
endif() endif()

View file

@ -164,6 +164,23 @@ void GraphicsPage::setupOgre()
QString ogreCfg = QString::fromStdString(mCfg.getOgreConfigPath().string()); QString ogreCfg = QString::fromStdString(mCfg.getOgreConfigPath().string());
file.setFileName(ogreCfg); file.setFileName(ogreCfg);
//we need to check that the path to the configuration file exists before we
//try and create an instance of Ogre::Root otherwise Ogre raises an exception
QDir configDir = QFileInfo(file).dir();
if ( !configDir.exists() && !configDir.mkpath(configDir.path()) )
{
QMessageBox msgBox;
msgBox.setWindowTitle("Error creating config file");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(QString(tr("<br><b>Failed to create the configuration file</b><br><br> \
Make sure you have write access to<br>%1<br><br>")).arg(configDir.path()));
msgBox.exec();
QApplication::exit(1);
return;
}
try try
{ {
mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log"); mOgre = new Ogre::Root(pluginCfg.toStdString(), file.fileName().toStdString(), "./launcherOgre.log");
@ -183,7 +200,8 @@ void GraphicsPage::setupOgre()
qCritical("Error creating Ogre::Root, the error reported was:\n %s", qPrintable(ogreError)); qCritical("Error creating Ogre::Root, the error reported was:\n %s", qPrintable(ogreError));
std::exit(1); QApplication::exit(1);
return;
} }
// Get the available renderers and put them in the combobox // Get the available renderers and put them in the combobox
@ -216,7 +234,8 @@ void GraphicsPage::setupOgre()
Please make sure the plugins.cfg file exists and contains a valid rendering plugin.<br>")); Please make sure the plugins.cfg file exists and contains a valid rendering plugin.<br>"));
msgBox.exec(); msgBox.exec();
std::exit(1); QApplication::exit(1);
return;
} }
// Now fill the GUI elements // Now fill the GUI elements
@ -388,7 +407,7 @@ void GraphicsPage::writeConfig()
if (!ogreError.isEmpty()) { if (!ogreError.isEmpty()) {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setWindowTitle("Error validating configuration"); msgBox.setWindowTitle("Error validating Ogre configuration");
msgBox.setIcon(QMessageBox::Critical); msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>A problem occured while validating the graphics options</b><br><br> \ msgBox.setText(tr("<br><b>A problem occured while validating the graphics options</b><br><br> \
@ -401,11 +420,34 @@ void GraphicsPage::writeConfig()
qCritical("Error validating configuration"); qCritical("Error validating configuration");
std::exit(1); QApplication::exit(1);
return;
} }
// Write the settings to the config file // Write the settings to the config file
mOgre->saveConfig();
try
{
mOgre->saveConfig();
}
catch(Ogre::Exception &ex)
{
QString ogreError = QString::fromStdString(ex.getFullDescription().c_str());
QMessageBox msgBox;
msgBox.setWindowTitle("Error writing Ogre configuration file");
msgBox.setIcon(QMessageBox::Critical);
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setText(tr("<br><b>Could not write the graphics configuration</b><br><br> \
Please make sure you have the right permissions and try again.<br><br> \
Press \"Show Details...\" for more information.<br>"));
msgBox.setDetailedText(ogreError);
msgBox.exec();
qCritical("Error saving Ogre configuration, the error reported was:\n %s", qPrintable(ogreError));
QApplication::exit(1);
}
} }

View file

@ -1,30 +0,0 @@
######################################################################
# Automatically generated by qmake (2.01a) Fri Jun 24 21:14:15 2011
######################################################################
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += combobox.hpp \
datafilespage.hpp \
graphicspage.hpp \
lineedit.hpp \
maindialog.hpp \
naturalsort.hpp \
playpage.hpp \
pluginsmodel.hpp \
pluginsview.hpp
SOURCES += datafilespage.cpp \
graphicspage.cpp \
lineedit.cpp \
main.cpp \
maindialog.cpp \
naturalsort.cpp \
playpage.cpp \
pluginsmodel.cpp \
pluginsview.cpp
RESOURCES += resources.qrc
win32:RC_FILE = launcher.rc

View file

@ -340,7 +340,7 @@ void MainDialog::writeConfig()
Please make sure you have the right permissions and try again.<br>").arg(file.fileName())); Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
msgBox.exec(); msgBox.exec();
std::exit(1); QApplication::exit(1);
} }
QTextStream in(&file); QTextStream in(&file);
@ -366,7 +366,7 @@ void MainDialog::writeConfig()
Please make sure you have the right permissions and try again.<br>").arg(file.fileName())); Please make sure you have the right permissions and try again.<br>").arg(file.fileName()));
msgBox.exec(); msgBox.exec();
std::exit(1);; QApplication::exit(1);
} }
file.write(buffer); file.write(buffer);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View file

@ -59,13 +59,15 @@ add_openmw_dir (mwmechanics
# Main executable # Main executable
add_executable(openmw add_executable(openmw
${COMPONENTS} ${COMPONENTS_HEADER}
${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
${CONPONENT_FILES}
${OPENMW_FILES} ${OPENMW_FILES}
${GAME} ${GAME_HEADER} ${GAME} ${GAME_HEADER}
${APPLE_BUNDLE_RESOURCES} ${APPLE_BUNDLE_RESOURCES}
) )
target_link_libraries (openmw components)
# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING # Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING
# when we change the backend. # when we change the backend.
include_directories(${SOUND_INPUT_INCLUDES} ${BULLET_INCLUDE_DIRS}) include_directories(${SOUND_INPUT_INCLUDES} ${BULLET_INCLUDE_DIRS})

View file

@ -295,6 +295,14 @@ void OMW::Engine::go()
mOgre = new OEngine::Render::OgreRenderer; mOgre = new OEngine::Render::OgreRenderer;
//we need to ensure the path to the configuration exists before creating an
//instance of ogre root so that Ogre doesn't raise an exception when trying to
//access it
const boost::filesystem::path configPath = mCfgMgr.getOgreConfigPath().parent_path();
if ( !boost::filesystem::exists(configPath) )
{
boost::filesystem::create_directories(configPath);
}
mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()), mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()),
mCfgMgr.getOgreConfigPath().string(), mCfgMgr.getOgreConfigPath().string(),
mCfgMgr.getLogPath().string() + std::string("/"), mCfgMgr.getLogPath().string() + std::string("/"),

View file

@ -21,7 +21,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -21,7 +21,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -16,10 +16,7 @@ namespace MWClass
{ {
// TODO check stacking // TODO check stacking
ESMS::LiveCellRef<T, MWWorld::RefData> cellRef; ESMS::LiveCellRef<T, MWWorld::RefData> cellRef(ptr.getCellRef(), ptr.get<T>()->base);
cellRef.base = ptr.get<T>()->base;
cellRef.ref = ptr.getCellRef();
cellRef.mData = ptr.getRefData(); cellRef.mData = ptr.getRefData();
containerStore.list.push_back (cellRef); containerStore.list.push_back (cellRef);

View file

@ -33,7 +33,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh("meshes\\" + model); cellRender.insertMesh("meshes\\" + model);
cellRender.insertActorPhysics(); cellRender.insertActorPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -28,7 +28,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -28,7 +28,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -64,7 +64,7 @@ namespace MWClass
std::string hairModel = "meshes\\" + std::string hairModel = "meshes\\" +
environment.mWorld->getStore().bodyParts.find(hairID)->model; environment.mWorld->getStore().bodyParts.find(hairID)->model;
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
//TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the //TODO: define consts for each bodypart e.g. chest, foot, wrist... and put the parts in the

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -19,7 +19,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref, true); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData, true);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -24,7 +24,7 @@ namespace MWClass
const std::string &model = ref->base->model; const std::string &model = ref->base->model;
if (!model.empty()) if (!model.empty())
{ {
MWRender::Rendering rendering (cellRender, ref->ref); MWRender::Rendering rendering (cellRender, ref->ref, ref->mData);
cellRender.insertMesh ("meshes\\" + model); cellRender.insertMesh ("meshes\\" + model);
cellRender.insertObjectPhysics(); cellRender.insertObjectPhysics();
ref->mData.setHandle (rendering.end (ref->mData.isEnabled())); ref->mData.setHandle (rendering.end (ref->mData.isEnabled()));

View file

@ -35,7 +35,7 @@ namespace MWRender
virtual ~CellRenderImp() {} virtual ~CellRenderImp() {}
/// start inserting a new reference. /// start inserting a new reference.
virtual void insertBegin (ESM::CellRef &ref, bool static_ = false) = 0; virtual void insertBegin (ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false) = 0;
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0; virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements) = 0;
/// insert a mesh related to the most recent insertBegin call. /// insert a mesh related to the most recent insertBegin call.
@ -71,10 +71,10 @@ namespace MWRender
public: public:
Rendering (CellRenderImp& cellRender, ESM::CellRef &ref, bool static_ = false) Rendering (CellRenderImp& cellRender, ESM::CellRef& ref, MWWorld::RefData& refData, bool static_ = false)
: mCellRender (cellRender), mEnd (false) : mCellRender (cellRender), mEnd (false)
{ {
mCellRender.insertBegin (ref, static_); mCellRender.insertBegin (ref, refData, static_);
} }
~Rendering() ~Rendering()

View file

@ -44,7 +44,7 @@ ExteriorCellRender::ExteriorCellRender(ESMS::CellStore<MWWorld::RefData> &_cell,
void ExteriorCellRender::insertBegin (ESM::CellRef &ref, bool static_) void ExteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_)
{ {
assert (!mInsert); assert (!mInsert);

View file

@ -71,7 +71,7 @@ namespace MWRender
Ogre::ColourValue mAmbientColor; Ogre::ColourValue mAmbientColor;
/// start inserting a new reference. /// start inserting a new reference.
virtual void insertBegin (ESM::CellRef &ref, bool static_ = false); virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false);
/// insert a mesh related to the most recent insertBegin call. /// insert a mesh related to the most recent insertBegin call.
virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements); virtual void insertMesh(const std::string &mesh, Ogre::Vector3 vec, Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName, std::string sceneParent[], int elements);

View file

@ -35,14 +35,14 @@ bool InteriorCellRender::lightOutQuadInLin = false;
// start inserting a new reference. // start inserting a new reference.
void InteriorCellRender::insertBegin (ESM::CellRef &ref, bool static_) void InteriorCellRender::insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_)
{ {
assert (!insert); assert (!insert);
// Create and place scene node for this object // Create and place scene node for this object
insert = base->createChildSceneNode(); insert = base->createChildSceneNode();
const float *f = ref.pos.pos; const float *f = refData.getPosition().pos;
insert->setPosition(f[0], f[1], f[2]); insert->setPosition(f[0], f[1], f[2]);
insert->setScale(ref.scale, ref.scale, ref.scale); insert->setScale(ref.scale, ref.scale, ref.scale);

View file

@ -66,7 +66,7 @@ namespace MWRender
Ogre::ColourValue ambientColor; Ogre::ColourValue ambientColor;
/// start inserting a new reference. /// start inserting a new reference.
virtual void insertBegin (ESM::CellRef &ref, bool static_ = false); virtual void insertBegin (ESM::CellRef &ref, MWWorld::RefData& refData, bool static_ = false);
virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements); virtual void rotateMesh(Ogre::Vector3 axis, Ogre::Radian angle, std::string sceneNodeName[], int elements);
virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements); virtual void scaleMesh(Ogre::Vector3 axis, std::string sceneNodeName[], int elements);
/// insert a mesh related to the most recent insertBegin call. /// insert a mesh related to the most recent insertBegin call.

View file

@ -196,8 +196,10 @@ namespace MWScript
double diff[3]; double diff[3];
const float* const pos1 = ref.getRefData().getPosition().pos;
const float* const pos2 = ref2.getRefData().getPosition().pos;
for (int i=0; i<3; ++i) for (int i=0; i<3; ++i)
diff[i] = ref.getCellRef().pos.pos[i] - ref2.getCellRef().pos.pos[i]; diff[i] = pos1[i] - pos2[i];
return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]); return std::sqrt (diff[0]*diff[0] + diff[1]*diff[1] + diff[2]*diff[2]);
} }

View file

@ -17,7 +17,10 @@ namespace MWWorld
mName = player->name; mName = player->name;
mMale = !(player->flags & ESM::NPC::Female); mMale = !(player->flags & ESM::NPC::Female);
mRace = player->race; mRace = player->race;
mPlayer.ref.pos.pos[0] = mPlayer.ref.pos.pos[1] = mPlayer.ref.pos.pos[2] = 0;
float* playerPos = mPlayer.mData.getPosition().pos;
playerPos[0] = playerPos[1] = playerPos[2] = 0;
std::cout << renderer->getHandle(); std::cout << renderer->getHandle();
mPlayer.mData.setHandle (renderer->getHandle()); mPlayer.mData.setHandle (renderer->getHandle());
/// \todo Do not make a copy of classes defined in esm/p records. /// \todo Do not make a copy of classes defined in esm/p records.

View file

@ -43,9 +43,13 @@ namespace MWWorld
boost::shared_ptr<ContainerStore<RefData> > mContainerStore; boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
public: ESM::Position mPosition;
public:
RefData(const ESMS::CellRef& cr) : mHasLocals (false), mEnabled (true),
mCount (1), mPosition(cr.pos), mBaseNode(0) {}
RefData() : mHasLocals (false), mEnabled (true), mCount (1),mBaseNode(0) {}
std::string getHandle() std::string getHandle()
{ {
@ -114,6 +118,11 @@ namespace MWWorld
{ {
return mContainerStore; return mContainerStore;
} }
ESM::Position& getPosition()
{
return mPosition;
}
}; };
} }

View file

@ -552,9 +552,9 @@ namespace MWWorld
void World::moveObjectImp (Ptr ptr, float x, float y, float z) void World::moveObjectImp (Ptr ptr, float x, float y, float z)
{ {
ptr.getCellRef().pos.pos[0] = x; ptr.getRefData().getPosition().pos[0] = x;
ptr.getCellRef().pos.pos[1] = y; ptr.getRefData().getPosition().pos[1] = y;
ptr.getCellRef().pos.pos[2] = z; ptr.getRefData().getPosition().pos[2] = z;
if (ptr==mPlayer->getPlayer()) if (ptr==mPlayer->getPlayer())
{ {
@ -571,7 +571,7 @@ namespace MWWorld
if (currentCell->cell->data.gridX!=cellX || currentCell->cell->data.gridY!=cellY) if (currentCell->cell->data.gridX!=cellX || currentCell->cell->data.gridY!=cellY)
{ {
mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getCellRef().pos, false); mWorldScene->changeCell (cellX, cellY, mPlayer->getPlayer().getRefData().getPosition(), false);
} }
} }

View file

@ -2,8 +2,23 @@
macro (add_openmw_dir dir) macro (add_openmw_dir dir)
set (files) set (files)
foreach (u ${ARGN}) foreach (u ${ARGN})
list (APPEND files "${dir}/${u}.*") file (GLOB ALL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.*")
list (APPEND OPENMW_FILES "${dir}/${u}") foreach (f ${ALL})
list (APPEND files "${f}")
list (APPEND OPENMW_FILES "${f}")
endforeach (f)
endforeach (u) endforeach (u)
source_group ("apps\\openmw\\${dir}" FILES ${files}) source_group ("apps\\openmw\\${dir}" FILES ${files})
endmacro (add_openmw_dir) endmacro (add_openmw_dir)
macro (add_component_dir dir)
set (files)
foreach (u ${ARGN})
file (GLOB ALL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.*")
foreach (f ${ALL})
list (APPEND files "${f}")
list (APPEND COMPONENT_FILES "${f}")
endforeach (f)
endforeach (u)
source_group ("components\\${dir}" FILES ${files})
endmacro (add_component_dir)

66
components/CMakeLists.txt Normal file
View file

@ -0,0 +1,66 @@
project (Components)
# source files
add_component_dir (bsa
bsa_archive bsa_file
)
add_component_dir (cfg
configurationmanager
)
add_component_dir (nif
controlled effect nif_types record controller extra node record_ptr data nif_file property
)
add_component_dir (nifogre
ogre_nif_loader
)
add_component_dir (nifbullet
bullet_nif_loader
)
add_component_dir (to_utf8
to_utf8
)
add_component_dir (file_finder
file_finder filename_less search
)
add_component_dir (esm_store
cell_store reclists store
)
add_component_dir (esm
attr defs esm_reader loadacti loadalch loadappa loadarmo loadbody loadbook loadbsgn loadcell
loadclas loadclot loadcont loadcrea loadcrec loaddial loaddoor loadench loadfact loadglob loadgmst
loadinfo loadingr loadland loadlevlist loadligh loadlocks loadltex loadmgef loadmisc loadnpcc
loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat
loadweap records
)
add_component_dir (misc
slice_array stringops
)
add_component_dir (files
linuxpath windowspath macospath path multidircollection collections fileops
)
add_component_dir (compiler
context controlparser errorhandler exception exprparser extensions fileparser generator
lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler
stringparser tokenloc
)
add_component_dir (interpreter
context controlopcodes genericopcodes installopcodes interpreter localopcodes mathopcodes
miscopcodes opcodes runtime scriptopcodes spatialopcodes types
)
include_directories(${BULLET_INCLUDE_DIRS})
add_library (components STATIC ${COMPONENT_FILES})

View file

@ -26,9 +26,20 @@ namespace ESMS
using namespace ESM; using namespace ESM;
/// A reference to one object (of any type) in a cell. /// A reference to one object (of any type) in a cell.
///
/// Constructing this with a CellRef instance in the constructor means that
/// in practice (where D is RefData) the possibly mutable data is copied
/// across to mData. If later adding data (such as position) to CellRef
/// this would have to be manually copied across.
template <typename X, typename D> template <typename X, typename D>
struct LiveCellRef struct LiveCellRef
{ {
LiveCellRef(const CellRef& cref, const X* b = NULL) : base(b), ref(cref),
mData(ref) {}
LiveCellRef(const X* b = NULL) : base(b), mData(ref) {}
// The object that this instance is based on. // The object that this instance is based on.
const X* base; const X* base;
@ -59,11 +70,7 @@ namespace ESMS
if(obj == NULL) if(obj == NULL)
throw std::runtime_error("Error resolving cell reference " + ref.refID); throw std::runtime_error("Error resolving cell reference " + ref.refID);
LiveRef lr; list.push_back(LiveRef(ref, obj));
lr.ref = ref;
lr.base = obj;
list.push_back(lr);
} }
LiveRef *find (const std::string& name) LiveRef *find (const std::string& name)