forked from mirror/openmw-tes3mp
commit
436548413e
31 changed files with 671 additions and 650 deletions
28
.travis.yml
28
.travis.yml
|
@ -16,6 +16,26 @@ env:
|
||||||
# via the "travis encrypt" command using the project repo's public key
|
# via the "travis encrypt" command using the project repo's public key
|
||||||
- secure: "jybGzAdUbqt9vWR/GEnRd96BgAi/7Zd1+2HK68j/i/8+/1YH2XxLOy4Jv/DUBhBlJIkxs/Xv8dRcUlFOclZDHX1d/9Qnsqd3oUVkD7k1y7cTOWy9TBQaE/v/kZo3LpzA3xPwwthrb0BvqIbOfIELi5fS5s8ba85WFRg3AX70wWE="
|
- secure: "jybGzAdUbqt9vWR/GEnRd96BgAi/7Zd1+2HK68j/i/8+/1YH2XxLOy4Jv/DUBhBlJIkxs/Xv8dRcUlFOclZDHX1d/9Qnsqd3oUVkD7k1y7cTOWy9TBQaE/v/kZo3LpzA3xPwwthrb0BvqIbOfIELi5fS5s8ba85WFRg3AX70wWE="
|
||||||
addons:
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- sourceline: 'ppa:openmw/openmw'
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-precise-3.6
|
||||||
|
packages: [
|
||||||
|
# Dev
|
||||||
|
clang-3.6, libunshield-dev, libtinyxml-dev,
|
||||||
|
# Tests
|
||||||
|
libgtest-dev, google-mock,
|
||||||
|
# Boost
|
||||||
|
libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev, libboost-thread-dev,
|
||||||
|
# FFmpeg
|
||||||
|
libavcodec-dev, libavformat-dev, libavutil-dev, libswscale-dev,
|
||||||
|
# Audio & Video
|
||||||
|
libsdl2-dev, libqt4-dev, libopenal-dev,
|
||||||
|
# The other from OpenMW ppa
|
||||||
|
libbullet-dev, libswresample-dev, libopenscenegraph-dev, libmygui-dev
|
||||||
|
]
|
||||||
|
|
||||||
coverity_scan:
|
coverity_scan:
|
||||||
project:
|
project:
|
||||||
name: "OpenMW/openmw"
|
name: "OpenMW/openmw"
|
||||||
|
@ -33,12 +53,8 @@ matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- env: ANALYZE="scan-build-3.6 --use-cc clang-3.6 --use-c++ clang++-3.6 "
|
- env: ANALYZE="scan-build-3.6 --use-cc clang-3.6 --use-c++ clang++-3.6 "
|
||||||
|
|
||||||
before_install:
|
before_install: ./CI/before_install.${TRAVIS_OS_NAME}.sh
|
||||||
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./CI/before_install.linux.sh; fi
|
before_script: ./CI/before_script.${TRAVIS_OS_NAME}.sh
|
||||||
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./CI/before_install.osx.sh; fi
|
|
||||||
before_script:
|
|
||||||
- if [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./CI/before_script.linux.sh; fi
|
|
||||||
- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./CI/before_script.osx.sh; fi
|
|
||||||
script:
|
script:
|
||||||
- cd ./build
|
- cd ./build
|
||||||
- if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then ${ANALYZE}make -j3; fi
|
- if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then ${ANALYZE}make -j3; fi
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ "${ANALYZE}" ]; then
|
# build libgtest & libgtest_main
|
||||||
echo "yes" | sudo add-apt-repository "deb http://llvm.org/apt/`lsb_release -sc`/ llvm-toolchain-`lsb_release -sc`-3.6 main"
|
|
||||||
wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "yes" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse"
|
|
||||||
echo "yes" | sudo apt-add-repository ppa:openmw/openmw
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -qq libgtest-dev google-mock
|
|
||||||
sudo apt-get install -qq libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev
|
|
||||||
sudo apt-get install -qq libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev
|
|
||||||
sudo apt-get install -qq libbullet-dev libopenscenegraph-dev libmygui-dev libsdl2-dev libunshield-dev libtinyxml-dev libopenal-dev libqt4-dev
|
|
||||||
if [ "${ANALYZE}" ]; then sudo apt-get install -qq clang-3.6; fi
|
|
||||||
sudo mkdir /usr/src/gtest/build
|
sudo mkdir /usr/src/gtest/build
|
||||||
cd /usr/src/gtest/build
|
cd /usr/src/gtest/build
|
||||||
sudo cmake .. -DBUILD_SHARED_LIBS=1
|
sudo cmake .. -DBUILD_SHARED_LIBS=1
|
||||||
|
|
|
@ -557,12 +557,9 @@ printf "SDL 2.0.3... "
|
||||||
eval 7z x -y SDL2-2.0.3.zip $STRIP
|
eval 7z x -y SDL2-2.0.3.zip $STRIP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SDL_SDK="`real_pwd`/SDL2-2.0.3"
|
export SDL2DIR="`real_pwd`/SDL2-2.0.3"
|
||||||
add_cmake_opts -DSDL2_INCLUDE_DIR="$SDL_SDK/include" \
|
|
||||||
-DSDL2MAIN_LIBRARY="$SDL_SDK/lib/x$ARCHSUFFIX/SDL2main.lib" \
|
|
||||||
-DSDL2_LIBRARY_PATH="$SDL_SDK/lib/x$ARCHSUFFIX/SDL2.lib"
|
|
||||||
|
|
||||||
add_runtime_dlls `pwd`/SDL2-2.0.3/lib/x$ARCHSUFFIX/SDL2.dll
|
add_runtime_dlls $SDL2DIR/lib/x$ARCHSUFFIX/SDL2.dll
|
||||||
|
|
||||||
echo Done.
|
echo Done.
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ cmake \
|
||||||
-D CMAKE_BUILD_TYPE=Debug \
|
-D CMAKE_BUILD_TYPE=Debug \
|
||||||
-D OPENMW_OSX_DEPLOYMENT=TRUE \
|
-D OPENMW_OSX_DEPLOYMENT=TRUE \
|
||||||
-D DESIRED_QT_VERSION=5 \
|
-D DESIRED_QT_VERSION=5 \
|
||||||
-D OSG_PLUGIN_LIB_SEARCH_PATH="$DEPENDENCIES_ROOT/lib/osgPlugins-3.4.0" \
|
|
||||||
-D BUILD_ESMTOOL=FALSE \
|
-D BUILD_ESMTOOL=FALSE \
|
||||||
-D BUILD_MYGUI_PLUGIN=FALSE \
|
-D BUILD_MYGUI_PLUGIN=FALSE \
|
||||||
-G"Unix Makefiles" \
|
-G"Unix Makefiles" \
|
||||||
|
|
|
@ -229,55 +229,16 @@ endif()
|
||||||
IF(BUILD_OPENMW OR BUILD_OPENCS)
|
IF(BUILD_OPENMW OR BUILD_OPENCS)
|
||||||
|
|
||||||
find_package(OpenSceneGraph 3.3.4 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle osgUtil osgFX)
|
find_package(OpenSceneGraph 3.3.4 REQUIRED osgDB osgViewer osgText osgGA osgAnimation osgParticle osgUtil osgFX)
|
||||||
|
|
||||||
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
|
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
get_filename_component(OSG_LIB_DIR ${OSGDB_LIBRARY} DIRECTORY)
|
||||||
|
set(OSGPlugins_LIB_DIR "${OSG_LIB_DIR}/osgPlugins-${OPENSCENEGRAPH_VERSION}")
|
||||||
|
|
||||||
if(OSG_STATIC)
|
if(OSG_STATIC)
|
||||||
macro(use_static_osg_plugin_library PLUGIN_NAME)
|
|
||||||
set(PLUGIN_NAME_DBG ${PLUGIN_NAME}d ${PLUGIN_NAME}D ${PLUGIN_NAME}_d ${PLUGIN_NAME}_D ${PLUGIN_NAME}_debug ${PLUGIN_NAME})
|
|
||||||
|
|
||||||
# For now, users wishing to do a static build will need to pass the path to where the plugins reside
|
|
||||||
# More clever logic would need to deduce the path, probably installed under <OpenSceneGraph>/lib/osgPlugins-<X.X.X>
|
|
||||||
include(FindPkgMacros)
|
|
||||||
find_library(${PLUGIN_NAME}_LIBRARY_REL NAMES ${PLUGIN_NAME} HINTS ${OSG_PLUGIN_LIB_SEARCH_PATH})
|
|
||||||
find_library(${PLUGIN_NAME}_LIBRARY_DBG NAMES ${PLUGIN_NAME_DBG} HINTS ${OSG_PLUGIN_LIB_SEARCH_PATH})
|
|
||||||
make_library_set(${PLUGIN_NAME}_LIBRARY)
|
|
||||||
|
|
||||||
if("${${PLUGIN_NAME}_LIBRARY}" STREQUAL "")
|
|
||||||
message(FATAL_ERROR "Unable to find static OpenSceneGraph plugin: ${PLUGIN_NAME}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(OPENSCENEGRAPH_LIBRARIES ${OPENSCENEGRAPH_LIBRARIES} ${${PLUGIN_NAME}_LIBRARY})
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
add_definitions(-DOSG_LIBRARY_STATIC)
|
add_definitions(-DOSG_LIBRARY_STATIC)
|
||||||
|
|
||||||
set(PLUGIN_LIST
|
find_package(OSGPlugins REQUIRED COMPONENTS osgdb_png osgdb_tga osgdb_dds osgdb_jpeg)
|
||||||
osgdb_png # depends on libpng, zlib
|
list(APPEND OPENSCENEGRAPH_LIBRARIES ${OSGPlugins_LIBRARIES})
|
||||||
osgdb_tga
|
|
||||||
osgdb_dds
|
|
||||||
osgdb_jpeg # depends on libjpeg
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach(PLUGIN ${PLUGIN_LIST})
|
|
||||||
use_static_osg_plugin_library(${PLUGIN})
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# OSG static plugins need to linked against their respective dependencies
|
|
||||||
set(PLUGIN_DEPS_LIST
|
|
||||||
PNG # needed by osgdb_png
|
|
||||||
ZLIB # needed by osgdb_png
|
|
||||||
JPEG # needed by osgdb_jpeg
|
|
||||||
)
|
|
||||||
|
|
||||||
macro(use_static_osg_plugin_dep DEPENDENCY)
|
|
||||||
find_package(${DEPENDENCY} REQUIRED)
|
|
||||||
|
|
||||||
set(OPENSCENEGRAPH_LIBRARIES ${OPENSCENEGRAPH_LIBRARIES} ${${DEPENDENCY}_LIBRARIES})
|
|
||||||
endmacro()
|
|
||||||
foreach(DEPENDENCY ${PLUGIN_DEPS_LIST})
|
|
||||||
use_static_osg_plugin_dep(${DEPENDENCY})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(QT_STATIC)
|
if(QT_STATIC)
|
||||||
|
@ -793,11 +754,14 @@ if (APPLE)
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach (PLUGIN_NAME ${USED_OSG_PLUGINS})
|
foreach (PLUGIN_NAME ${USED_OSG_PLUGINS})
|
||||||
set(PLUGIN_ABS "${OSG_PLUGIN_LIB_SEARCH_PATH}/${PLUGIN_NAME}.so")
|
set(PLUGIN_ABS "${OSGPlugins_LIB_DIR}/${PLUGIN_NAME}.so")
|
||||||
set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS})
|
set(ABSOLUTE_PLUGINS ${PLUGIN_ABS} ${ABSOLUTE_PLUGINS})
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
get_filename_component(OSG_PLUGIN_PREFIX_DIR "${OSG_PLUGIN_LIB_SEARCH_PATH}" NAME)
|
get_filename_component(OSG_PLUGIN_PREFIX_DIR "${OSGPlugins_LIB_DIR}" NAME)
|
||||||
|
if (NOT OSG_PLUGIN_PREFIX_DIR)
|
||||||
|
message(FATAL_ERROR "Can't get directory name for OSG plugins from '${OSGPlugins_LIB_DIR}'")
|
||||||
|
endif()
|
||||||
|
|
||||||
# installs used plugins in bundle at given path (bundle_path must be relative to ${CMAKE_INSTALL_PREFIX})
|
# installs used plugins in bundle at given path (bundle_path must be relative to ${CMAKE_INSTALL_PREFIX})
|
||||||
# and returns list of install paths for all installed plugins
|
# and returns list of install paths for all installed plugins
|
||||||
|
|
|
@ -188,6 +188,7 @@ void CSMPrefs::State::declare()
|
||||||
"Shift-acceleration factor during drag operations", 4.0).
|
"Shift-acceleration factor during drag operations", 4.0).
|
||||||
setTooltip ("Acceleration factor during drag operations while holding down shift").
|
setTooltip ("Acceleration factor during drag operations while holding down shift").
|
||||||
setRange (0.001, 100.0);
|
setRange (0.001, 100.0);
|
||||||
|
declareDouble ("rotate-factor", "Free rotation factor", 0.007).setPrecision(4).setRange(0.0001, 0.1);
|
||||||
|
|
||||||
declareCategory ("Tooltips");
|
declareCategory ("Tooltips");
|
||||||
declareBool ("scene", "Show Tooltips in 3D scenes", true);
|
declareBool ("scene", "Show Tooltips in 3D scenes", true);
|
||||||
|
|
|
@ -27,6 +27,68 @@ int CSVRender::InstanceMode::getSubModeFromId (const std::string& id) const
|
||||||
return id=="move" ? 0 : (id=="rotate" ? 1 : 2);
|
return id=="move" ? 0 : (id=="rotate" ? 1 : 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::Vec3f CSVRender::InstanceMode::quatToEuler(const osg::Quat& rot) const
|
||||||
|
{
|
||||||
|
const float Pi = 3.14159265f;
|
||||||
|
|
||||||
|
float x, y, z;
|
||||||
|
float test = 2 * (rot.w() * rot.y() + rot.x() * rot.z());
|
||||||
|
|
||||||
|
if (std::abs(test) >= 1.f)
|
||||||
|
{
|
||||||
|
x = atan2(rot.x(), rot.w());
|
||||||
|
y = (test > 0) ? (Pi / 2) : (-Pi / 2);
|
||||||
|
z = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = std::atan2(2 * (rot.w() * rot.x() - rot.y() * rot.z()), 1 - 2 * (rot.x() * rot.x() + rot.y() * rot.y()));
|
||||||
|
y = std::asin(test);
|
||||||
|
z = std::atan2(2 * (rot.w() * rot.z() - rot.x() * rot.y()), 1 - 2 * (rot.y() * rot.y() + rot.z() * rot.z()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return osg::Vec3f(-x, -y, -z);
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Quat CSVRender::InstanceMode::eulerToQuat(const osg::Vec3f& euler) const
|
||||||
|
{
|
||||||
|
osg::Quat xr = osg::Quat(-euler[0], osg::Vec3f(1,0,0));
|
||||||
|
osg::Quat yr = osg::Quat(-euler[1], osg::Vec3f(0,1,0));
|
||||||
|
osg::Quat zr = osg::Quat(-euler[2], osg::Vec3f(0,0,1));
|
||||||
|
|
||||||
|
return zr * yr * xr;
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Vec3f CSVRender::InstanceMode::getSelectionCenter(const std::vector<osg::ref_ptr<TagBase> >& selection) const
|
||||||
|
{
|
||||||
|
osg::Vec3f center = osg::Vec3f(0, 0, 0);
|
||||||
|
int objectCount = 0;
|
||||||
|
|
||||||
|
for (std::vector<osg::ref_ptr<TagBase> >::const_iterator iter (selection.begin()); iter!=selection.end(); ++iter)
|
||||||
|
{
|
||||||
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (iter->get()))
|
||||||
|
{
|
||||||
|
const ESM::Position& position = objectTag->mObject->getPosition();
|
||||||
|
center += osg::Vec3f(position.pos[0], position.pos[1], position.pos[2]);
|
||||||
|
|
||||||
|
++objectCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
center /= objectCount;
|
||||||
|
|
||||||
|
return center;
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::Vec3f CSVRender::InstanceMode::getScreenCoords(const osg::Vec3f& pos)
|
||||||
|
{
|
||||||
|
osg::Matrix viewMatrix = getWorldspaceWidget().getCamera()->getViewMatrix();
|
||||||
|
osg::Matrix projMatrix = getWorldspaceWidget().getCamera()->getProjectionMatrix();
|
||||||
|
osg::Matrix windowMatrix = getWorldspaceWidget().getCamera()->getViewport()->computeWindowMatrix();
|
||||||
|
osg::Matrix combined = viewMatrix * projMatrix * windowMatrix;
|
||||||
|
|
||||||
|
return pos * combined;
|
||||||
|
}
|
||||||
|
|
||||||
CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
||||||
: EditMode (worldspaceWidget, QIcon (":placeholder"), Mask_Reference, "Instance editing",
|
: EditMode (worldspaceWidget, QIcon (":placeholder"), Mask_Reference, "Instance editing",
|
||||||
parent), mSubMode (0), mSubModeId ("move"), mSelectionMode (0), mDragMode (DragMode_None),
|
parent), mSubMode (0), mSubModeId ("move"), mSelectionMode (0), mDragMode (DragMode_None),
|
||||||
|
@ -44,14 +106,16 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar)
|
||||||
"Rotate selected instances"
|
"Rotate selected instances"
|
||||||
"<ul><li>Use {scene-edit-primary} to rotate instances freely</li>"
|
"<ul><li>Use {scene-edit-primary} to rotate instances freely</li>"
|
||||||
"<li>Use {scene-edit-secondary} to rotate instances within the grid</li>"
|
"<li>Use {scene-edit-secondary} to rotate instances within the grid</li>"
|
||||||
|
"<li>The center of the view acts as the axis of rotation</li>"
|
||||||
"</ul>"
|
"</ul>"
|
||||||
"<font color=Red>Not implemented yet</font color>");
|
"<font color=Red>Grid rotate not implemented yet</font color>");
|
||||||
mSubMode->addButton (":placeholder", "scale",
|
mSubMode->addButton (":placeholder", "scale",
|
||||||
"Scale selected instances"
|
"Scale selected instances"
|
||||||
"<ul><li>Use {scene-edit-primary} to scale instances freely</li>"
|
"<ul><li>Use {scene-edit-primary} to scale instances freely</li>"
|
||||||
"<li>Use {scene-edit-secondary} to scale instances along the grid</li>"
|
"<li>Use {scene-edit-secondary} to scale instances along the grid</li>"
|
||||||
|
"<li>The scaling rate is based on how close the start of a drag is to the center of the screen</li>"
|
||||||
"</ul>"
|
"</ul>"
|
||||||
"<font color=Red>Not implemented yet</font color>");
|
"<font color=Red>Grid scale not implemented yet</font color>");
|
||||||
|
|
||||||
mSubMode->setButton (mSubModeId);
|
mSubMode->setButton (mSubModeId);
|
||||||
|
|
||||||
|
@ -152,6 +216,11 @@ bool CSVRender::InstanceMode::primaryEditStartDrag (const QPoint& pos)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask());
|
WorldspaceHitResult hit = getWorldspaceWidget().mousePick (pos, getWorldspaceWidget().getInteractionMask());
|
||||||
|
|
||||||
|
std::vector<osg::ref_ptr<TagBase> > selection = getWorldspaceWidget().getSelection (Mask_Reference);
|
||||||
|
if (selection.empty())
|
||||||
|
{
|
||||||
|
// Only change selection at the start of drag if no object is already selected
|
||||||
if (hit.tag && CSMPrefs::get()["3D Scene Input"]["context-select"].isTrue())
|
if (hit.tag && CSMPrefs::get()["3D Scene Input"]["context-select"].isTrue())
|
||||||
{
|
{
|
||||||
getWorldspaceWidget().clearSelection (Mask_Reference);
|
getWorldspaceWidget().clearSelection (Mask_Reference);
|
||||||
|
@ -162,22 +231,44 @@ bool CSVRender::InstanceMode::primaryEditStartDrag (const QPoint& pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<osg::ref_ptr<TagBase> > selection =
|
selection = getWorldspaceWidget().getSelection (Mask_Reference);
|
||||||
getWorldspaceWidget().getSelection (Mask_Reference);
|
|
||||||
|
|
||||||
if (selection.empty())
|
if (selection.empty())
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (std::vector<osg::ref_ptr<TagBase> >::iterator iter (selection.begin());
|
for (std::vector<osg::ref_ptr<TagBase> >::iterator iter (selection.begin());
|
||||||
iter!=selection.end(); ++iter)
|
iter!=selection.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (iter->get()))
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (iter->get()))
|
||||||
|
{
|
||||||
|
if (mSubModeId == "move")
|
||||||
{
|
{
|
||||||
objectTag->mObject->setEdited (Object::Override_Position);
|
objectTag->mObject->setEdited (Object::Override_Position);
|
||||||
|
mDragMode = DragMode_Move;
|
||||||
}
|
}
|
||||||
|
else if (mSubModeId == "rotate")
|
||||||
|
{
|
||||||
|
objectTag->mObject->setEdited (Object::Override_Rotation);
|
||||||
|
mDragMode = DragMode_Rotate;
|
||||||
}
|
}
|
||||||
|
else if (mSubModeId == "scale")
|
||||||
|
{
|
||||||
|
objectTag->mObject->setEdited (Object::Override_Scale);
|
||||||
|
mDragMode = DragMode_Scale;
|
||||||
|
|
||||||
// \todo check for sub-mode
|
// Calculate scale factor
|
||||||
|
std::vector<osg::ref_ptr<TagBase> > selection = getWorldspaceWidget().getEdited (Mask_Reference);
|
||||||
|
osg::Vec3f center = getScreenCoords(getSelectionCenter(selection));
|
||||||
|
|
||||||
|
int widgetHeight = getWorldspaceWidget().height();
|
||||||
|
|
||||||
|
float dx = pos.x() - center.x();
|
||||||
|
float dy = (widgetHeight - pos.y()) - center.y();
|
||||||
|
|
||||||
|
mUnitScaleDist = std::sqrt(dx * dx + dy * dy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (CSVRender::ObjectMarkerTag *objectTag = dynamic_cast<CSVRender::ObjectMarkerTag *> (hit.tag.get()))
|
if (CSVRender::ObjectMarkerTag *objectTag = dynamic_cast<CSVRender::ObjectMarkerTag *> (hit.tag.get()))
|
||||||
{
|
{
|
||||||
|
@ -186,8 +277,6 @@ bool CSVRender::InstanceMode::primaryEditStartDrag (const QPoint& pos)
|
||||||
else
|
else
|
||||||
mDragAxis = -1;
|
mDragAxis = -1;
|
||||||
|
|
||||||
mDragMode = DragMode_Move;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,48 +290,160 @@ bool CSVRender::InstanceMode::secondaryEditStartDrag (const QPoint& pos)
|
||||||
|
|
||||||
void CSVRender::InstanceMode::drag (const QPoint& pos, int diffX, int diffY, double speedFactor)
|
void CSVRender::InstanceMode::drag (const QPoint& pos, int diffX, int diffY, double speedFactor)
|
||||||
{
|
{
|
||||||
osg::Vec3f eye;
|
osg::Vec3f offset;
|
||||||
osg::Vec3f centre;
|
osg::Quat rotation;
|
||||||
osg::Vec3f up;
|
|
||||||
|
|
||||||
|
std::vector<osg::ref_ptr<TagBase> > selection = getWorldspaceWidget().getEdited (Mask_Reference);
|
||||||
|
|
||||||
|
if (mDragMode == DragMode_Move)
|
||||||
|
{
|
||||||
|
osg::Vec3f eye, centre, up;
|
||||||
getWorldspaceWidget().getCamera()->getViewMatrix().getLookAt (eye, centre, up);
|
getWorldspaceWidget().getCamera()->getViewMatrix().getLookAt (eye, centre, up);
|
||||||
|
|
||||||
osg::Vec3f offset;
|
|
||||||
|
|
||||||
if (diffY)
|
if (diffY)
|
||||||
|
{
|
||||||
offset += up * diffY * speedFactor;
|
offset += up * diffY * speedFactor;
|
||||||
|
}
|
||||||
if (diffX)
|
if (diffX)
|
||||||
|
{
|
||||||
offset += ((centre-eye) ^ up) * diffX * speedFactor;
|
offset += ((centre-eye) ^ up) * diffX * speedFactor;
|
||||||
|
}
|
||||||
|
|
||||||
switch (mDragMode)
|
|
||||||
{
|
|
||||||
case DragMode_Move:
|
|
||||||
{
|
|
||||||
if (mDragAxis!=-1)
|
if (mDragAxis!=-1)
|
||||||
|
{
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
|
{
|
||||||
if (i!=mDragAxis)
|
if (i!=mDragAxis)
|
||||||
offset[i] = 0;
|
offset[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (mDragMode == DragMode_Rotate)
|
||||||
|
{
|
||||||
|
osg::Vec3f eye, centre, up;
|
||||||
|
getWorldspaceWidget().getCamera()->getViewMatrix().getLookAt (eye, centre, up);
|
||||||
|
|
||||||
std::vector<osg::ref_ptr<TagBase> > selection =
|
float angle;
|
||||||
getWorldspaceWidget().getEdited (Mask_Reference);
|
osg::Vec3f axis;
|
||||||
|
|
||||||
for (std::vector<osg::ref_ptr<TagBase> >::iterator iter (selection.begin());
|
if (mDragAxis == -1)
|
||||||
iter!=selection.end(); ++iter)
|
{
|
||||||
|
// Free rotate
|
||||||
|
float rotationFactor = CSMPrefs::get()["3D Scene Input"]["rotate-factor"].toDouble() * speedFactor;
|
||||||
|
|
||||||
|
osg::Quat cameraRotation = getWorldspaceWidget().getCamera()->getInverseViewMatrix().getRotate();
|
||||||
|
|
||||||
|
osg::Vec3f camForward = centre - eye;
|
||||||
|
osg::Vec3f screenDir = cameraRotation * osg::Vec3f(diffX, diffY, 0);
|
||||||
|
screenDir.normalize();
|
||||||
|
|
||||||
|
angle = std::sqrt(diffX*diffX + diffY*diffY) * rotationFactor;
|
||||||
|
axis = screenDir ^ camForward;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Global axis rotation
|
||||||
|
osg::Vec3f camBack = eye - centre;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
if (i == mDragAxis)
|
||||||
|
axis[i] = 1;
|
||||||
|
else
|
||||||
|
axis[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flip axis if facing opposite side
|
||||||
|
if (camBack * axis < 0)
|
||||||
|
axis *= -1;
|
||||||
|
|
||||||
|
// Convert coordinate system
|
||||||
|
osg::Vec3f screenCenter = getScreenCoords(getSelectionCenter(selection));
|
||||||
|
|
||||||
|
int widgetHeight = getWorldspaceWidget().height();
|
||||||
|
|
||||||
|
float newX = pos.x() - screenCenter.x();
|
||||||
|
float newY = (widgetHeight - pos.y()) - screenCenter.y();
|
||||||
|
|
||||||
|
float oldX = newX - diffX;
|
||||||
|
float oldY = newY - diffY; // diffY appears to already be flipped
|
||||||
|
|
||||||
|
osg::Vec3f oldVec = osg::Vec3f(oldX, oldY, 0);
|
||||||
|
oldVec.normalize();
|
||||||
|
|
||||||
|
osg::Vec3f newVec = osg::Vec3f(newX, newY, 0);
|
||||||
|
newVec.normalize();
|
||||||
|
|
||||||
|
// Find angle and axis of rotation
|
||||||
|
angle = std::acos(oldVec * newVec) * speedFactor;
|
||||||
|
if (((oldVec ^ newVec) * camBack < 0) ^ (camBack.z() < 0))
|
||||||
|
angle *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rotation = osg::Quat(angle, axis);
|
||||||
|
}
|
||||||
|
else if (mDragMode == DragMode_Scale)
|
||||||
|
{
|
||||||
|
osg::Vec3f center = getScreenCoords(getSelectionCenter(selection));
|
||||||
|
|
||||||
|
// Calculate scaling distance/rate
|
||||||
|
int widgetHeight = getWorldspaceWidget().height();
|
||||||
|
|
||||||
|
float dx = pos.x() - center.x();
|
||||||
|
float dy = (widgetHeight - pos.y()) - center.y();
|
||||||
|
|
||||||
|
float dist = std::sqrt(dx * dx + dy * dy);
|
||||||
|
float scale = dist / mUnitScaleDist;
|
||||||
|
|
||||||
|
// Only uniform scaling is currently supported
|
||||||
|
offset = osg::Vec3f(scale, scale, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply
|
||||||
|
for (std::vector<osg::ref_ptr<TagBase> >::iterator iter (selection.begin()); iter!=selection.end(); ++iter)
|
||||||
{
|
{
|
||||||
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (iter->get()))
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (iter->get()))
|
||||||
|
{
|
||||||
|
if (mDragMode == DragMode_Move)
|
||||||
{
|
{
|
||||||
ESM::Position position = objectTag->mObject->getPosition();
|
ESM::Position position = objectTag->mObject->getPosition();
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
|
{
|
||||||
position.pos[i] += offset[i];
|
position.pos[i] += offset[i];
|
||||||
|
}
|
||||||
|
|
||||||
objectTag->mObject->setPosition(position.pos);
|
objectTag->mObject->setPosition(position.pos);
|
||||||
}
|
}
|
||||||
|
else if (mDragMode == DragMode_Rotate)
|
||||||
|
{
|
||||||
|
ESM::Position position = objectTag->mObject->getPosition();
|
||||||
|
|
||||||
|
osg::Quat currentRot = eulerToQuat(osg::Vec3f(position.rot[0], position.rot[1], position.rot[2]));
|
||||||
|
osg::Quat combined = currentRot * rotation;
|
||||||
|
|
||||||
|
osg::Vec3f euler = quatToEuler(combined);
|
||||||
|
// There appears to be a very rare rounding error that can cause asin to return NaN
|
||||||
|
if (!euler.isNaN())
|
||||||
|
{
|
||||||
|
position.rot[0] = euler.x();
|
||||||
|
position.rot[1] = euler.y();
|
||||||
|
position.rot[2] = euler.z();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
objectTag->mObject->setRotation(position.rot);
|
||||||
}
|
}
|
||||||
|
else if (mDragMode == DragMode_Scale)
|
||||||
|
{
|
||||||
|
// Reset scale
|
||||||
|
objectTag->mObject->setEdited(0);
|
||||||
|
objectTag->mObject->setEdited(Object::Override_Scale);
|
||||||
|
|
||||||
case DragMode_None: break;
|
float scale = objectTag->mObject->getScale();
|
||||||
|
scale *= offset.x();
|
||||||
|
|
||||||
|
objectTag->mObject->setScale (scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +459,8 @@ void CSVRender::InstanceMode::dragCompleted(const QPoint& pos)
|
||||||
switch (mDragMode)
|
switch (mDragMode)
|
||||||
{
|
{
|
||||||
case DragMode_Move: description = "Move Instances"; break;
|
case DragMode_Move: description = "Move Instances"; break;
|
||||||
|
case DragMode_Rotate: description = "Rotate Instances"; break;
|
||||||
|
case DragMode_Scale: description = "Scale Instances"; break;
|
||||||
|
|
||||||
case DragMode_None: break;
|
case DragMode_None: break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#ifndef CSV_RENDER_INSTANCEMODE_H
|
#ifndef CSV_RENDER_INSTANCEMODE_H
|
||||||
#define CSV_RENDER_INSTANCEMODE_H
|
#define CSV_RENDER_INSTANCEMODE_H
|
||||||
|
|
||||||
|
#include <osg/ref_ptr>
|
||||||
|
#include <osg/Quat>
|
||||||
|
#include <osg/Vec3f>
|
||||||
|
|
||||||
#include "editmode.hpp"
|
#include "editmode.hpp"
|
||||||
|
|
||||||
namespace CSVWidget
|
namespace CSVWidget
|
||||||
|
@ -10,6 +14,7 @@ namespace CSVWidget
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
|
class TagBase;
|
||||||
class InstanceSelectionMode;
|
class InstanceSelectionMode;
|
||||||
|
|
||||||
class InstanceMode : public EditMode
|
class InstanceMode : public EditMode
|
||||||
|
@ -19,7 +24,9 @@ namespace CSVRender
|
||||||
enum DragMode
|
enum DragMode
|
||||||
{
|
{
|
||||||
DragMode_None,
|
DragMode_None,
|
||||||
DragMode_Move
|
DragMode_Move,
|
||||||
|
DragMode_Rotate,
|
||||||
|
DragMode_Scale
|
||||||
};
|
};
|
||||||
|
|
||||||
CSVWidget::SceneToolMode *mSubMode;
|
CSVWidget::SceneToolMode *mSubMode;
|
||||||
|
@ -28,9 +35,16 @@ namespace CSVRender
|
||||||
DragMode mDragMode;
|
DragMode mDragMode;
|
||||||
int mDragAxis;
|
int mDragAxis;
|
||||||
bool mLocked;
|
bool mLocked;
|
||||||
|
float mUnitScaleDist;
|
||||||
|
|
||||||
int getSubModeFromId (const std::string& id) const;
|
int getSubModeFromId (const std::string& id) const;
|
||||||
|
|
||||||
|
osg::Vec3f quatToEuler(const osg::Quat& quat) const;
|
||||||
|
osg::Quat eulerToQuat(const osg::Vec3f& euler) const;
|
||||||
|
|
||||||
|
osg::Vec3f getSelectionCenter(const std::vector<osg::ref_ptr<TagBase> >& selection) const;
|
||||||
|
osg::Vec3f getScreenCoords(const osg::Vec3f& pos);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent = 0);
|
InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent = 0);
|
||||||
|
|
|
@ -29,6 +29,13 @@
|
||||||
|
|
||||||
#include "mask.hpp"
|
#include "mask.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
const float CSVRender::Object::MarkerShaftWidth = 30;
|
||||||
|
const float CSVRender::Object::MarkerShaftBaseLength = 70;
|
||||||
|
const float CSVRender::Object::MarkerHeadWidth = 50;
|
||||||
|
const float CSVRender::Object::MarkerHeadLength = 50;
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -179,7 +186,21 @@ void CSVRender::Object::updateMarker()
|
||||||
{
|
{
|
||||||
if (mSubMode==0)
|
if (mSubMode==0)
|
||||||
{
|
{
|
||||||
mMarker[i] = makeMarker (i);
|
mMarker[i] = makeMoveOrScaleMarker (i);
|
||||||
|
mMarker[i]->setUserData(new ObjectMarkerTag (this, i));
|
||||||
|
|
||||||
|
mRootNode->addChild (mMarker[i]);
|
||||||
|
}
|
||||||
|
else if (mSubMode==1)
|
||||||
|
{
|
||||||
|
mMarker[i] = makeRotateMarker (i);
|
||||||
|
mMarker[i]->setUserData(new ObjectMarkerTag (this, i));
|
||||||
|
|
||||||
|
mRootNode->addChild (mMarker[i]);
|
||||||
|
}
|
||||||
|
else if (mSubMode==2)
|
||||||
|
{
|
||||||
|
mMarker[i] = makeMoveOrScaleMarker (i);
|
||||||
mMarker[i]->setUserData(new ObjectMarkerTag (this, i));
|
mMarker[i]->setUserData(new ObjectMarkerTag (this, i));
|
||||||
|
|
||||||
mRootNode->addChild (mMarker[i]);
|
mRootNode->addChild (mMarker[i]);
|
||||||
|
@ -188,16 +209,11 @@ void CSVRender::Object::updateMarker()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> CSVRender::Object::makeMarker (int axis)
|
osg::ref_ptr<osg::Node> CSVRender::Object::makeMoveOrScaleMarker (int axis)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry);
|
osg::ref_ptr<osg::Geometry> geometry (new osg::Geometry);
|
||||||
|
|
||||||
const float shaftWidth = 10;
|
float shaftLength = MarkerShaftBaseLength + mBaseNode->getBound().radius();
|
||||||
const float shaftBaseLength = 50;
|
|
||||||
const float headWidth = 30;
|
|
||||||
const float headLength = 30;
|
|
||||||
|
|
||||||
float shaftLength = shaftBaseLength + mBaseNode->getBound().radius();
|
|
||||||
|
|
||||||
// shaft
|
// shaft
|
||||||
osg::Vec3Array *vertices = new osg::Vec3Array;
|
osg::Vec3Array *vertices = new osg::Vec3Array;
|
||||||
|
@ -206,20 +222,20 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeMarker (int axis)
|
||||||
{
|
{
|
||||||
float length = i ? shaftLength : 0;
|
float length = i ? shaftLength : 0;
|
||||||
|
|
||||||
vertices->push_back (getMarkerPosition (-shaftWidth/2, -shaftWidth/2, length, axis));
|
vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, -MarkerShaftWidth/2, length, axis));
|
||||||
vertices->push_back (getMarkerPosition (-shaftWidth/2, shaftWidth/2, length, axis));
|
vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, MarkerShaftWidth/2, length, axis));
|
||||||
vertices->push_back (getMarkerPosition (shaftWidth/2, shaftWidth/2, length, axis));
|
vertices->push_back (getMarkerPosition (MarkerShaftWidth/2, MarkerShaftWidth/2, length, axis));
|
||||||
vertices->push_back (getMarkerPosition (shaftWidth/2, -shaftWidth/2, length, axis));
|
vertices->push_back (getMarkerPosition (MarkerShaftWidth/2, -MarkerShaftWidth/2, length, axis));
|
||||||
}
|
}
|
||||||
|
|
||||||
// head backside
|
// head backside
|
||||||
vertices->push_back (getMarkerPosition (-headWidth/2, -headWidth/2, shaftLength, axis));
|
vertices->push_back (getMarkerPosition (-MarkerHeadWidth/2, -MarkerHeadWidth/2, shaftLength, axis));
|
||||||
vertices->push_back (getMarkerPosition (-headWidth/2, headWidth/2, shaftLength, axis));
|
vertices->push_back (getMarkerPosition (-MarkerHeadWidth/2, MarkerHeadWidth/2, shaftLength, axis));
|
||||||
vertices->push_back (getMarkerPosition (headWidth/2, headWidth/2, shaftLength, axis));
|
vertices->push_back (getMarkerPosition (MarkerHeadWidth/2, MarkerHeadWidth/2, shaftLength, axis));
|
||||||
vertices->push_back (getMarkerPosition (headWidth/2, -headWidth/2, shaftLength, axis));
|
vertices->push_back (getMarkerPosition (MarkerHeadWidth/2, -MarkerHeadWidth/2, shaftLength, axis));
|
||||||
|
|
||||||
// head
|
// head
|
||||||
vertices->push_back (getMarkerPosition (0, 0, shaftLength+headLength, axis));
|
vertices->push_back (getMarkerPosition (0, 0, shaftLength+MarkerHeadLength, axis));
|
||||||
|
|
||||||
geometry->setVertexArray (vertices);
|
geometry->setVertexArray (vertices);
|
||||||
|
|
||||||
|
@ -285,6 +301,87 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeMarker (int axis)
|
||||||
return geode;
|
return geode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
|
||||||
|
{
|
||||||
|
const float Pi = 3.14159265f;
|
||||||
|
|
||||||
|
const float InnerRadius = mBaseNode->getBound().radius();
|
||||||
|
const float OuterRadius = InnerRadius + MarkerShaftWidth;
|
||||||
|
|
||||||
|
const float SegmentDistance = 100.f;
|
||||||
|
const size_t SegmentCount = std::min(64, std::max(8, (int)(OuterRadius * 2 * Pi / SegmentDistance)));
|
||||||
|
const size_t VerticesPerSegment = 4;
|
||||||
|
const size_t IndicesPerSegment = 24;
|
||||||
|
|
||||||
|
const size_t VertexCount = SegmentCount * VerticesPerSegment;
|
||||||
|
const size_t IndexCount = SegmentCount * IndicesPerSegment;
|
||||||
|
|
||||||
|
const float Angle = 2 * Pi / SegmentCount;
|
||||||
|
|
||||||
|
const unsigned short IndexPattern[IndicesPerSegment] =
|
||||||
|
{
|
||||||
|
0, 4, 5, 0, 5, 1,
|
||||||
|
2, 6, 4, 2, 4, 0,
|
||||||
|
3, 7, 6, 3, 6, 2,
|
||||||
|
1, 5, 7, 1, 7, 3
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(VertexCount);
|
||||||
|
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(1);
|
||||||
|
osg::ref_ptr<osg::DrawElementsUShort> primitives = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES,
|
||||||
|
IndexCount);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < SegmentCount; ++i)
|
||||||
|
{
|
||||||
|
size_t index = i * VerticesPerSegment;
|
||||||
|
|
||||||
|
float innerX = InnerRadius * std::cos(i * Angle);
|
||||||
|
float innerY = InnerRadius * std::sin(i * Angle);
|
||||||
|
|
||||||
|
float outerX = OuterRadius * std::cos(i * Angle);
|
||||||
|
float outerY = OuterRadius * std::sin(i * Angle);
|
||||||
|
|
||||||
|
vertices->at(index++) = getMarkerPosition(innerX, innerY, MarkerShaftWidth / 2, axis);
|
||||||
|
vertices->at(index++) = getMarkerPosition(innerX, innerY, -MarkerShaftWidth / 2, axis);
|
||||||
|
vertices->at(index++) = getMarkerPosition(outerX, outerY, MarkerShaftWidth / 2, axis);
|
||||||
|
vertices->at(index++) = getMarkerPosition(outerX, outerY, -MarkerShaftWidth / 2, axis);
|
||||||
|
}
|
||||||
|
|
||||||
|
colors->at(0) = osg::Vec4f (axis==0 ? 1.0f : 0.2f, axis==1 ? 1.0f : 0.2f, axis==2 ? 1.0f : 0.2f, 1.0f);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < SegmentCount; ++i)
|
||||||
|
{
|
||||||
|
size_t indices[IndicesPerSegment];
|
||||||
|
for (size_t j = 0; j < IndicesPerSegment; ++j)
|
||||||
|
{
|
||||||
|
indices[j] = i * VerticesPerSegment + j;
|
||||||
|
|
||||||
|
if (indices[j] >= VertexCount)
|
||||||
|
indices[j] -= VertexCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t offset = i * IndicesPerSegment;
|
||||||
|
for (size_t j = 0; j < IndicesPerSegment; ++j)
|
||||||
|
{
|
||||||
|
primitives->setElement(offset++, indices[IndexPattern[j]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
geometry->setVertexArray(vertices);
|
||||||
|
geometry->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||||
|
geometry->addPrimitiveSet(primitives);
|
||||||
|
|
||||||
|
geometry->getOrCreateStateSet()->setMode (GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
||||||
|
geode->addDrawable (geometry);
|
||||||
|
|
||||||
|
return geode;
|
||||||
|
}
|
||||||
|
|
||||||
osg::Vec3f CSVRender::Object::getMarkerPosition (float x, float y, float z, int axis)
|
osg::Vec3f CSVRender::Object::getMarkerPosition (float x, float y, float z, int axis)
|
||||||
{
|
{
|
||||||
switch (axis)
|
switch (axis)
|
||||||
|
@ -494,7 +591,7 @@ ESM::Position CSVRender::Object::getPosition() const
|
||||||
|
|
||||||
float CSVRender::Object::getScale() const
|
float CSVRender::Object::getScale() const
|
||||||
{
|
{
|
||||||
return mOverrideFlags & Override_Scale ? mScaleOverride : getReference().mScale;
|
return (mOverrideFlags & Override_Scale) ? mScaleOverride : getReference().mScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Object::setPosition (const float position[3])
|
void CSVRender::Object::setPosition (const float position[3])
|
||||||
|
|
|
@ -78,6 +78,11 @@ namespace CSVRender
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
static const float MarkerShaftWidth;
|
||||||
|
static const float MarkerShaftBaseLength;
|
||||||
|
static const float MarkerHeadWidth;
|
||||||
|
static const float MarkerHeadLength;
|
||||||
|
|
||||||
CSMWorld::Data& mData;
|
CSMWorld::Data& mData;
|
||||||
std::string mReferenceId;
|
std::string mReferenceId;
|
||||||
std::string mReferenceableId;
|
std::string mReferenceableId;
|
||||||
|
@ -89,7 +94,7 @@ namespace CSVRender
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
bool mForceBaseToZero;
|
bool mForceBaseToZero;
|
||||||
ESM::Position mPositionOverride;
|
ESM::Position mPositionOverride;
|
||||||
int mScaleOverride;
|
float mScaleOverride;
|
||||||
int mOverrideFlags;
|
int mOverrideFlags;
|
||||||
osg::ref_ptr<osg::Node> mMarker[3];
|
osg::ref_ptr<osg::Node> mMarker[3];
|
||||||
int mSubMode;
|
int mSubMode;
|
||||||
|
@ -115,7 +120,8 @@ namespace CSVRender
|
||||||
|
|
||||||
void updateMarker();
|
void updateMarker();
|
||||||
|
|
||||||
osg::ref_ptr<osg::Node> makeMarker (int axis);
|
osg::ref_ptr<osg::Node> makeMoveOrScaleMarker (int axis);
|
||||||
|
osg::ref_ptr<osg::Node> makeRotateMarker (int axis);
|
||||||
|
|
||||||
osg::Vec3f getMarkerPosition (float x, float y, float z, int axis);
|
osg::Vec3f getMarkerPosition (float x, float y, float z, int axis);
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ namespace
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
CharacterCreation::CharacterCreation(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem)
|
CharacterCreation::CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem)
|
||||||
: mViewer(viewer)
|
: mParent(parent)
|
||||||
, mResourceSystem(resourceSystem)
|
, mResourceSystem(resourceSystem)
|
||||||
, mNameDialog(0)
|
, mNameDialog(0)
|
||||||
, mRaceDialog(0)
|
, mRaceDialog(0)
|
||||||
|
@ -152,7 +152,7 @@ namespace MWGui
|
||||||
case GM_Race:
|
case GM_Race:
|
||||||
MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog);
|
MWBase::Environment::get().getWindowManager()->removeDialog(mRaceDialog);
|
||||||
mRaceDialog = 0;
|
mRaceDialog = 0;
|
||||||
mRaceDialog = new RaceDialog(mViewer, mResourceSystem);
|
mRaceDialog = new RaceDialog(mParent, mResourceSystem);
|
||||||
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
|
mRaceDialog->setNextButtonShow(mCreationStage >= CSE_RaceChosen);
|
||||||
mRaceDialog->setRaceId(mPlayerRaceId);
|
mRaceDialog->setRaceId(mPlayerRaceId);
|
||||||
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
mRaceDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onRaceDialogDone);
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
|
|
||||||
#include "../mwmechanics/stat.hpp"
|
#include "../mwmechanics/stat.hpp"
|
||||||
|
|
||||||
namespace osgViewer
|
namespace osg
|
||||||
{
|
{
|
||||||
class Viewer;
|
class Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
|
@ -39,7 +39,7 @@ namespace MWGui
|
||||||
public:
|
public:
|
||||||
typedef std::vector<int> SkillList;
|
typedef std::vector<int> SkillList;
|
||||||
|
|
||||||
CharacterCreation(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem);
|
CharacterCreation(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
|
||||||
~CharacterCreation();
|
~CharacterCreation();
|
||||||
|
|
||||||
//Show a dialog
|
//Show a dialog
|
||||||
|
@ -51,7 +51,7 @@ namespace MWGui
|
||||||
void configureSkills (const SkillList& major, const SkillList& minor);
|
void configureSkills (const SkillList& major, const SkillList& minor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
osgViewer::Viewer* mViewer;
|
osg::Group* mParent;
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
|
|
||||||
//Dialogs
|
//Dialogs
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
InventoryWindow::InventoryWindow(DragAndDrop* dragAndDrop, osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem)
|
InventoryWindow::InventoryWindow(DragAndDrop* dragAndDrop, osg::Group* parent, Resource::ResourceSystem* resourceSystem)
|
||||||
: WindowPinnableBase("openmw_inventory_window.layout")
|
: WindowPinnableBase("openmw_inventory_window.layout")
|
||||||
, mDragAndDrop(dragAndDrop)
|
, mDragAndDrop(dragAndDrop)
|
||||||
, mSelectedItem(-1)
|
, mSelectedItem(-1)
|
||||||
|
@ -65,7 +65,7 @@ namespace MWGui
|
||||||
, mGuiMode(GM_Inventory)
|
, mGuiMode(GM_Inventory)
|
||||||
, mLastXSize(0)
|
, mLastXSize(0)
|
||||||
, mLastYSize(0)
|
, mLastYSize(0)
|
||||||
, mPreview(new MWRender::InventoryPreview(viewer, resourceSystem, MWMechanics::getPlayer()))
|
, mPreview(new MWRender::InventoryPreview(parent, resourceSystem, MWMechanics::getPlayer()))
|
||||||
, mTrading(false)
|
, mTrading(false)
|
||||||
{
|
{
|
||||||
mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture()));
|
mPreviewTexture.reset(new osgMyGUI::OSGTexture(mPreview->getTexture()));
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
namespace osgViewer
|
namespace osg
|
||||||
{
|
{
|
||||||
class Viewer;
|
class Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
|
@ -37,7 +37,7 @@ namespace MWGui
|
||||||
class InventoryWindow : public WindowPinnableBase
|
class InventoryWindow : public WindowPinnableBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InventoryWindow(DragAndDrop* dragAndDrop, osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem);
|
InventoryWindow(DragAndDrop* dragAndDrop, osg::Group* parent, Resource::ResourceSystem* resourceSystem);
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ namespace
|
||||||
namespace MWGui
|
namespace MWGui
|
||||||
{
|
{
|
||||||
|
|
||||||
RaceDialog::RaceDialog(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem)
|
RaceDialog::RaceDialog(osg::Group* parent, Resource::ResourceSystem* resourceSystem)
|
||||||
: WindowModal("openmw_chargen_race.layout")
|
: WindowModal("openmw_chargen_race.layout")
|
||||||
, mViewer(viewer)
|
, mParent(parent)
|
||||||
, mResourceSystem(resourceSystem)
|
, mResourceSystem(resourceSystem)
|
||||||
, mGenderIndex(0)
|
, mGenderIndex(0)
|
||||||
, mFaceIndex(0)
|
, mFaceIndex(0)
|
||||||
|
@ -136,7 +136,7 @@ namespace MWGui
|
||||||
mPreview.reset(NULL);
|
mPreview.reset(NULL);
|
||||||
mPreviewTexture.reset(NULL);
|
mPreviewTexture.reset(NULL);
|
||||||
|
|
||||||
mPreview.reset(new MWRender::RaceSelectionPreview(mViewer, mResourceSystem));
|
mPreview.reset(new MWRender::RaceSelectionPreview(mParent, mResourceSystem));
|
||||||
mPreview->rebuild();
|
mPreview->rebuild();
|
||||||
mPreview->setAngle (mCurrentAngle);
|
mPreview->setAngle (mCurrentAngle);
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ namespace ESM
|
||||||
struct NPC;
|
struct NPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace osgViewer
|
namespace osg
|
||||||
{
|
{
|
||||||
class Viewer;
|
class Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Resource
|
namespace Resource
|
||||||
|
@ -34,7 +34,7 @@ namespace MWGui
|
||||||
class RaceDialog : public WindowModal
|
class RaceDialog : public WindowModal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RaceDialog(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem);
|
RaceDialog(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
|
||||||
|
|
||||||
enum Gender
|
enum Gender
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ namespace MWGui
|
||||||
|
|
||||||
void getBodyParts (int part, std::vector<std::string>& out);
|
void getBodyParts (int part, std::vector<std::string>& out);
|
||||||
|
|
||||||
osgViewer::Viewer* mViewer;
|
osg::Group* mParent;
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
|
|
||||||
std::vector<std::string> mAvailableHeads;
|
std::vector<std::string> mAvailableHeads;
|
||||||
|
|
|
@ -282,7 +282,7 @@ namespace MWGui
|
||||||
|
|
||||||
mRecharge = new Recharge();
|
mRecharge = new Recharge();
|
||||||
mMenu = new MainMenu(w, h, mResourceSystem->getVFS(), mVersionDescription);
|
mMenu = new MainMenu(w, h, mResourceSystem->getVFS(), mVersionDescription);
|
||||||
mLocalMapRender = new MWRender::LocalMap(mViewer);
|
mLocalMapRender = new MWRender::LocalMap(mViewer->getSceneData()->asGroup());
|
||||||
mMap = new MapWindow(mCustomMarkers, mDragAndDrop, mLocalMapRender);
|
mMap = new MapWindow(mCustomMarkers, mDragAndDrop, mLocalMapRender);
|
||||||
trackWindow(mMap, "map");
|
trackWindow(mMap, "map");
|
||||||
mStatsWindow = new StatsWindow(mDragAndDrop);
|
mStatsWindow = new StatsWindow(mDragAndDrop);
|
||||||
|
@ -293,7 +293,7 @@ namespace MWGui
|
||||||
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
|
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
|
||||||
mJournal = JournalWindow::create(JournalViewModel::create (), questList);
|
mJournal = JournalWindow::create(JournalViewModel::create (), questList);
|
||||||
mMessageBoxManager = new MessageBoxManager(mStore->get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
|
mMessageBoxManager = new MessageBoxManager(mStore->get<ESM::GameSetting>().find("fMessageTimePerChar")->getFloat());
|
||||||
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer, mResourceSystem);
|
mInventoryWindow = new InventoryWindow(mDragAndDrop, mViewer->getSceneData()->asGroup(), mResourceSystem);
|
||||||
mTradeWindow = new TradeWindow();
|
mTradeWindow = new TradeWindow();
|
||||||
trackWindow(mTradeWindow, "barter");
|
trackWindow(mTradeWindow, "barter");
|
||||||
mSpellBuyingWindow = new SpellBuyingWindow();
|
mSpellBuyingWindow = new SpellBuyingWindow();
|
||||||
|
@ -350,7 +350,7 @@ namespace MWGui
|
||||||
|
|
||||||
mHud->setVisible(mHudEnabled);
|
mHud->setVisible(mHudEnabled);
|
||||||
|
|
||||||
mCharGen = new CharacterCreation(mViewer, mResourceSystem);
|
mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem);
|
||||||
|
|
||||||
// Setup player stats
|
// Setup player stats
|
||||||
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
for (int i = 0; i < ESM::Attribute::Length; ++i)
|
||||||
|
@ -384,7 +384,7 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
disallowAll();
|
disallowAll();
|
||||||
delete mCharGen;
|
delete mCharGen;
|
||||||
mCharGen = new CharacterCreation(mViewer, mResourceSystem);
|
mCharGen = new CharacterCreation(mViewer->getSceneData()->asGroup(), mResourceSystem);
|
||||||
mGuiModes.clear();
|
mGuiModes.clear();
|
||||||
MWBase::Environment::get().getInputManager()->changeInputMode(false);
|
MWBase::Environment::get().getInputManager()->changeInputMode(false);
|
||||||
mHud->unsetSelectedWeapon();
|
mHud->unsetSelectedWeapon();
|
||||||
|
|
|
@ -1542,9 +1542,10 @@ void CharacterController::update(float duration)
|
||||||
mAnimation->disable(mAnimQueue.front().mGroup);
|
mAnimation->disable(mAnimQueue.front().mGroup);
|
||||||
mAnimQueue.pop_front();
|
mAnimQueue.pop_front();
|
||||||
|
|
||||||
|
bool loopfallback = (mAnimQueue.front().mGroup.compare(0,4,"idle") == 0);
|
||||||
mAnimation->play(mAnimQueue.front().mGroup, Priority_Default,
|
mAnimation->play(mAnimQueue.front().mGroup, Priority_Default,
|
||||||
MWRender::Animation::BlendMask_All, false,
|
MWRender::Animation::BlendMask_All, false,
|
||||||
1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount);
|
1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount, loopfallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1822,9 +1823,10 @@ void CharacterController::update(float duration)
|
||||||
mAnimation->disable(mAnimQueue.front().mGroup);
|
mAnimation->disable(mAnimQueue.front().mGroup);
|
||||||
mAnimQueue.pop_front();
|
mAnimQueue.pop_front();
|
||||||
|
|
||||||
|
bool loopfallback = (mAnimQueue.front().mGroup.compare(0,4,"idle") == 0);
|
||||||
mAnimation->play(mAnimQueue.front().mGroup, Priority_Default,
|
mAnimation->play(mAnimQueue.front().mGroup, Priority_Default,
|
||||||
MWRender::Animation::BlendMask_All, false,
|
MWRender::Animation::BlendMask_All, false,
|
||||||
1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount);
|
1.0f, "start", "stop", 0.0f, mAnimQueue.front().mLoopCount, loopfallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2023,9 +2025,10 @@ bool CharacterController::playGroup(const std::string &groupname, int mode, int
|
||||||
mCurrentIdle.clear();
|
mCurrentIdle.clear();
|
||||||
|
|
||||||
mIdleState = CharState_SpecialIdle;
|
mIdleState = CharState_SpecialIdle;
|
||||||
|
bool loopfallback = (entry.mGroup.compare(0,4,"idle") == 0);
|
||||||
mAnimation->play(groupname, Priority_Default,
|
mAnimation->play(groupname, Priority_Default,
|
||||||
MWRender::Animation::BlendMask_All, false, 1.0f,
|
MWRender::Animation::BlendMask_All, false, 1.0f,
|
||||||
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1);
|
((mode==2) ? "loop start" : "start"), "stop", 0.0f, count-1, loopfallback);
|
||||||
}
|
}
|
||||||
else if(mode == 0)
|
else if(mode == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -591,11 +591,14 @@ namespace MWPhysics
|
||||||
|
|
||||||
btCompoundShape* compound = static_cast<btCompoundShape*>(mShapeInstance->getCollisionShape());
|
btCompoundShape* compound = static_cast<btCompoundShape*>(mShapeInstance->getCollisionShape());
|
||||||
|
|
||||||
for (std::map<int, int>::iterator it = mShapeInstance->mAnimatedShapes.begin(); it != mShapeInstance->mAnimatedShapes.end();)
|
for (std::map<int, int>::const_iterator it = mShapeInstance->mAnimatedShapes.begin(); it != mShapeInstance->mAnimatedShapes.end(); ++it)
|
||||||
{
|
{
|
||||||
int recIndex = it->first;
|
int recIndex = it->first;
|
||||||
int shapeIndex = it->second;
|
int shapeIndex = it->second;
|
||||||
|
|
||||||
|
std::map<int, osg::NodePath>::iterator nodePathFound = mRecIndexToNodePath.find(recIndex);
|
||||||
|
if (nodePathFound == mRecIndexToNodePath.end())
|
||||||
|
{
|
||||||
NifOsg::FindGroupByRecIndex visitor(recIndex);
|
NifOsg::FindGroupByRecIndex visitor(recIndex);
|
||||||
mPtr.getRefData().getBaseNode()->accept(visitor);
|
mPtr.getRefData().getBaseNode()->accept(visitor);
|
||||||
if (!visitor.mFound)
|
if (!visitor.mFound)
|
||||||
|
@ -603,28 +606,13 @@ namespace MWPhysics
|
||||||
std::cerr << "animateCollisionShapes: Can't find node " << recIndex << std::endl;
|
std::cerr << "animateCollisionShapes: Can't find node " << recIndex << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
osg::NodePath nodePath = visitor.mFoundPath;
|
||||||
osg::NodePath path = visitor.mFoundPath;
|
nodePath.erase(nodePath.begin());
|
||||||
path.erase(path.begin());
|
nodePathFound = mRecIndexToNodePath.insert(std::make_pair(recIndex, nodePath)).first;
|
||||||
|
|
||||||
// Attempt to remove "animated" shapes that are not actually animated
|
|
||||||
// We may get these because the BulletNifLoader does not know if a .kf file with additional controllers will be attached later on.
|
|
||||||
// On the first animateCollisionShapes call, we'll consider the graph completely loaded (with extra controllers and what not),
|
|
||||||
// so now we can better decide if the shape is really animated.
|
|
||||||
bool animated = false;
|
|
||||||
for (osg::NodePath::iterator nodePathIt = path.begin(); nodePathIt != path.end(); ++nodePathIt)
|
|
||||||
{
|
|
||||||
osg::Node* node = *nodePathIt;
|
|
||||||
if (node->getUpdateCallback())
|
|
||||||
animated = true;
|
|
||||||
}
|
|
||||||
if (!animated)
|
|
||||||
{
|
|
||||||
mShapeInstance->mAnimatedShapes.erase(it++);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Matrixf matrix = osg::computeLocalToWorld(path);
|
osg::NodePath& nodePath = nodePathFound->second;
|
||||||
|
osg::Matrixf matrix = osg::computeLocalToWorld(nodePath);
|
||||||
osg::Vec3f scale = matrix.getScale();
|
osg::Vec3f scale = matrix.getScale();
|
||||||
matrix.orthoNormalize(matrix);
|
matrix.orthoNormalize(matrix);
|
||||||
|
|
||||||
|
@ -634,10 +622,10 @@ namespace MWPhysics
|
||||||
for (int j=0; j<3; ++j)
|
for (int j=0; j<3; ++j)
|
||||||
transform.getBasis()[i][j] = matrix(j,i); // NB column/row major difference
|
transform.getBasis()[i][j] = matrix(j,i); // NB column/row major difference
|
||||||
|
|
||||||
|
if (compound->getLocalScaling() * toBullet(scale) != compound->getChildShape(shapeIndex)->getLocalScaling())
|
||||||
compound->getChildShape(shapeIndex)->setLocalScaling(compound->getLocalScaling() * toBullet(scale));
|
compound->getChildShape(shapeIndex)->setLocalScaling(compound->getLocalScaling() * toBullet(scale));
|
||||||
|
if (!(transform == compound->getChildTransform(shapeIndex)))
|
||||||
compound->updateChildTransform(shapeIndex, transform);
|
compound->updateChildTransform(shapeIndex, transform);
|
||||||
|
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
collisionWorld->updateSingleAabb(mCollisionObject.get());
|
collisionWorld->updateSingleAabb(mCollisionObject.get());
|
||||||
|
@ -646,6 +634,7 @@ namespace MWPhysics
|
||||||
private:
|
private:
|
||||||
std::auto_ptr<btCollisionObject> mCollisionObject;
|
std::auto_ptr<btCollisionObject> mCollisionObject;
|
||||||
osg::ref_ptr<Resource::BulletShapeInstance> mShapeInstance;
|
osg::ref_ptr<Resource::BulletShapeInstance> mShapeInstance;
|
||||||
|
std::map<int, osg::NodePath> mRecIndexToNodePath;
|
||||||
bool mSolid;
|
bool mSolid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include <osg/Texture2D>
|
#include <osg/Texture2D>
|
||||||
#include <osg/Camera>
|
#include <osg/Camera>
|
||||||
#include <osg/PositionAttitudeTransform>
|
#include <osg/PositionAttitudeTransform>
|
||||||
#include <osgViewer/Viewer>
|
|
||||||
#include <osg/LightModel>
|
#include <osg/LightModel>
|
||||||
|
#include <osg/LightSource>
|
||||||
#include <osgUtil/IntersectionVisitor>
|
#include <osgUtil/IntersectionVisitor>
|
||||||
#include <osgUtil/LineSegmentIntersector>
|
#include <osgUtil/LineSegmentIntersector>
|
||||||
|
|
||||||
|
@ -65,9 +65,9 @@ namespace MWRender
|
||||||
unsigned int mLastRenderedFrame;
|
unsigned int mLastRenderedFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
CharacterPreview::CharacterPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem,
|
CharacterPreview::CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem,
|
||||||
MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt)
|
MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt)
|
||||||
: mViewer(viewer)
|
: mParent(parent)
|
||||||
, mResourceSystem(resourceSystem)
|
, mResourceSystem(resourceSystem)
|
||||||
, mPosition(position)
|
, mPosition(position)
|
||||||
, mLookAt(lookAt)
|
, mLookAt(lookAt)
|
||||||
|
@ -93,7 +93,6 @@ namespace MWRender
|
||||||
mCamera->setViewport(0, 0, sizeX, sizeY);
|
mCamera->setViewport(0, 0, sizeX, sizeY);
|
||||||
mCamera->setRenderOrder(osg::Camera::PRE_RENDER);
|
mCamera->setRenderOrder(osg::Camera::PRE_RENDER);
|
||||||
mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture);
|
mCamera->attach(osg::Camera::COLOR_BUFFER, mTexture);
|
||||||
mCamera->setGraphicsContext(mViewer->getCamera()->getGraphicsContext());
|
|
||||||
|
|
||||||
mCamera->setNodeMask(Mask_RenderToTexture);
|
mCamera->setNodeMask(Mask_RenderToTexture);
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ namespace MWRender
|
||||||
mDrawOnceCallback = new DrawOnceCallback;
|
mDrawOnceCallback = new DrawOnceCallback;
|
||||||
mCamera->addUpdateCallback(mDrawOnceCallback);
|
mCamera->addUpdateCallback(mDrawOnceCallback);
|
||||||
|
|
||||||
mViewer->getSceneData()->asGroup()->addChild(mCamera);
|
mParent->addChild(mCamera);
|
||||||
|
|
||||||
mCharacter.mCell = NULL;
|
mCharacter.mCell = NULL;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +147,7 @@ namespace MWRender
|
||||||
CharacterPreview::~CharacterPreview ()
|
CharacterPreview::~CharacterPreview ()
|
||||||
{
|
{
|
||||||
mCamera->removeChildren(0, mCamera->getNumChildren());
|
mCamera->removeChildren(0, mCamera->getNumChildren());
|
||||||
mViewer->getSceneData()->asGroup()->removeChild(mCamera);
|
mParent->removeChild(mCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharacterPreview::getTextureWidth() const
|
int CharacterPreview::getTextureWidth() const
|
||||||
|
@ -191,8 +190,8 @@ namespace MWRender
|
||||||
// --------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
InventoryPreview::InventoryPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character)
|
InventoryPreview::InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character)
|
||||||
: CharacterPreview(viewer, resourceSystem, character, 512, 1024, osg::Vec3f(0, 700, 71), osg::Vec3f(0,0,71))
|
: CharacterPreview(parent, resourceSystem, character, 512, 1024, osg::Vec3f(0, 700, 71), osg::Vec3f(0,0,71))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,8 +319,8 @@ namespace MWRender
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
RaceSelectionPreview::RaceSelectionPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem)
|
RaceSelectionPreview::RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem)
|
||||||
: CharacterPreview(viewer, resourceSystem, MWMechanics::getPlayer(),
|
: CharacterPreview(parent, resourceSystem, MWMechanics::getPlayer(),
|
||||||
512, 512, osg::Vec3f(0, 125, 8), osg::Vec3f(0,0,8))
|
512, 512, osg::Vec3f(0, 125, 8), osg::Vec3f(0,0,8))
|
||||||
, mBase (*mCharacter.get<ESM::NPC>()->mBase)
|
, mBase (*mCharacter.get<ESM::NPC>()->mBase)
|
||||||
, mRef(&mBase)
|
, mRef(&mBase)
|
||||||
|
|
|
@ -16,11 +16,7 @@ namespace osg
|
||||||
{
|
{
|
||||||
class Texture2D;
|
class Texture2D;
|
||||||
class Camera;
|
class Camera;
|
||||||
}
|
class Group;
|
||||||
|
|
||||||
namespace osgViewer
|
|
||||||
{
|
|
||||||
class Viewer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
|
@ -32,7 +28,7 @@ namespace MWRender
|
||||||
class CharacterPreview
|
class CharacterPreview
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CharacterPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY,
|
CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY,
|
||||||
const osg::Vec3f& position, const osg::Vec3f& lookAt);
|
const osg::Vec3f& position, const osg::Vec3f& lookAt);
|
||||||
virtual ~CharacterPreview();
|
virtual ~CharacterPreview();
|
||||||
|
|
||||||
|
@ -53,7 +49,7 @@ namespace MWRender
|
||||||
virtual bool renderHeadOnly() { return false; }
|
virtual bool renderHeadOnly() { return false; }
|
||||||
virtual void onSetup();
|
virtual void onSetup();
|
||||||
|
|
||||||
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
osg::ref_ptr<osg::Group> mParent;
|
||||||
Resource::ResourceSystem* mResourceSystem;
|
Resource::ResourceSystem* mResourceSystem;
|
||||||
osg::ref_ptr<osg::Texture2D> mTexture;
|
osg::ref_ptr<osg::Texture2D> mTexture;
|
||||||
osg::ref_ptr<osg::Camera> mCamera;
|
osg::ref_ptr<osg::Camera> mCamera;
|
||||||
|
@ -76,7 +72,7 @@ namespace MWRender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InventoryPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character);
|
InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character);
|
||||||
|
|
||||||
void updatePtr(const MWWorld::Ptr& ptr);
|
void updatePtr(const MWWorld::Ptr& ptr);
|
||||||
|
|
||||||
|
@ -102,7 +98,7 @@ namespace MWRender
|
||||||
virtual void onSetup();
|
virtual void onSetup();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RaceSelectionPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem);
|
RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
|
||||||
virtual ~RaceSelectionPreview();
|
virtual ~RaceSelectionPreview();
|
||||||
|
|
||||||
void setAngle(float angleRadians);
|
void setAngle(float angleRadians);
|
||||||
|
|
|
@ -7,11 +7,10 @@
|
||||||
#include <osg/LightModel>
|
#include <osg/LightModel>
|
||||||
#include <osg/Texture2D>
|
#include <osg/Texture2D>
|
||||||
#include <osg/ComputeBoundsVisitor>
|
#include <osg/ComputeBoundsVisitor>
|
||||||
|
#include <osg/LightSource>
|
||||||
|
|
||||||
#include <osgDB/ReadFile>
|
#include <osgDB/ReadFile>
|
||||||
|
|
||||||
#include <osgViewer/Viewer>
|
|
||||||
|
|
||||||
#include <components/esm/fogstate.hpp>
|
#include <components/esm/fogstate.hpp>
|
||||||
#include <components/esm/loadcell.hpp>
|
#include <components/esm/loadcell.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
@ -68,16 +67,14 @@ namespace
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
{
|
{
|
||||||
|
|
||||||
LocalMap::LocalMap(osgViewer::Viewer* viewer)
|
LocalMap::LocalMap(osg::Group* root)
|
||||||
: mViewer(viewer)
|
: mRoot(root)
|
||||||
, mMapResolution(Settings::Manager::getInt("local map resolution", "Map"))
|
, mMapResolution(Settings::Manager::getInt("local map resolution", "Map"))
|
||||||
, mMapWorldSize(8192.f)
|
, mMapWorldSize(8192.f)
|
||||||
, mCellDistance(Settings::Manager::getInt("local map cell distance", "Map"))
|
, mCellDistance(Settings::Manager::getInt("local map cell distance", "Map"))
|
||||||
, mAngle(0.f)
|
, mAngle(0.f)
|
||||||
, mInterior(false)
|
, mInterior(false)
|
||||||
{
|
{
|
||||||
mRoot = mViewer->getSceneData()->asGroup();
|
|
||||||
|
|
||||||
SceneUtil::FindByNameVisitor find("Scene Root");
|
SceneUtil::FindByNameVisitor find("Scene Root");
|
||||||
mRoot->accept(find);
|
mRoot->accept(find);
|
||||||
mSceneRoot = find.mFoundNode;
|
mSceneRoot = find.mFoundNode;
|
||||||
|
@ -208,7 +205,6 @@ osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, f
|
||||||
|
|
||||||
camera->addChild(lightSource);
|
camera->addChild(lightSource);
|
||||||
camera->setStateSet(stateset);
|
camera->setStateSet(stateset);
|
||||||
camera->setGraphicsContext(mViewer->getCamera()->getGraphicsContext());
|
|
||||||
camera->setViewport(0, 0, mMapResolution, mMapResolution);
|
camera->setViewport(0, 0, mMapResolution, mMapResolution);
|
||||||
camera->setUpdateCallback(new CameraLocalUpdateCallback(this));
|
camera->setUpdateCallback(new CameraLocalUpdateCallback(this));
|
||||||
|
|
||||||
|
@ -311,7 +307,7 @@ void LocalMap::requestExteriorMap(const MWWorld::CellStore* cell)
|
||||||
int x = cell->getCell()->getGridX();
|
int x = cell->getCell()->getGridX();
|
||||||
int y = cell->getCell()->getGridY();
|
int y = cell->getCell()->getGridY();
|
||||||
|
|
||||||
osg::BoundingSphere bound = mViewer->getSceneData()->getBound();
|
osg::BoundingSphere bound = mSceneRoot->getBound();
|
||||||
float zmin = bound.center().z() - bound.radius();
|
float zmin = bound.center().z() - bound.radius();
|
||||||
float zmax = bound.center().z() + bound.radius();
|
float zmax = bound.center().z() + bound.radius();
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,6 @@ namespace ESM
|
||||||
struct FogTexture;
|
struct FogTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace osgViewer
|
|
||||||
{
|
|
||||||
class Viewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Texture2D;
|
class Texture2D;
|
||||||
|
@ -41,7 +36,7 @@ namespace MWRender
|
||||||
class LocalMap
|
class LocalMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocalMap(osgViewer::Viewer* viewer);
|
LocalMap(osg::Group* root);
|
||||||
~LocalMap();
|
~LocalMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,8 +101,6 @@ namespace MWRender
|
||||||
osg::Group* getRoot();
|
osg::Group* getRoot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
osg::ref_ptr<osgViewer::Viewer> mViewer;
|
|
||||||
|
|
||||||
osg::ref_ptr<osg::Group> mRoot;
|
osg::ref_ptr<osg::Group> mRoot;
|
||||||
osg::ref_ptr<osg::Node> mSceneRoot;
|
osg::ref_ptr<osg::Node> mSceneRoot;
|
||||||
|
|
||||||
|
|
|
@ -620,7 +620,6 @@ namespace MWRender
|
||||||
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
||||||
|
|
||||||
rttCamera->removeChildren(0, rttCamera->getNumChildren());
|
rttCamera->removeChildren(0, rttCamera->getNumChildren());
|
||||||
rttCamera->setGraphicsContext(NULL);
|
|
||||||
mRootNode->removeChild(rttCamera);
|
mRootNode->removeChild(rttCamera);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
50
cmake/FindOSGPlugins.cmake
Normal file
50
cmake/FindOSGPlugins.cmake
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
# This module accepts the following env variable
|
||||||
|
# OSGPlugins_LIB_DIR - <OpenSceneGraph>/lib/osgPlugins-<X.X.X> , path to search plugins
|
||||||
|
#
|
||||||
|
# Once done this will define
|
||||||
|
# OSGPlugins_FOUND - System has the all required components.
|
||||||
|
# OSGPlugins_LIBRARIES - Link these to use the required osg plugins components.
|
||||||
|
#
|
||||||
|
# Components:
|
||||||
|
# - osgdb_png
|
||||||
|
# - osgdb_tga
|
||||||
|
# - osgdb_dds
|
||||||
|
# - osgdb_jpeg
|
||||||
|
|
||||||
|
include(LibFindMacros)
|
||||||
|
include(Findosg_functions)
|
||||||
|
|
||||||
|
if (NOT OSGPlugins_LIB_DIR)
|
||||||
|
set(_mode WARNING)
|
||||||
|
if (OSGPlugins_FIND_REQUIRED)
|
||||||
|
set(_mode FATAL_ERROR)
|
||||||
|
endif()
|
||||||
|
message(${_mode} "OSGPlugins_LIB_DIR variable must be set")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(_library ${OSGPlugins_FIND_COMPONENTS})
|
||||||
|
string(TOUPPER ${_library} _library_uc)
|
||||||
|
set(_component OSGPlugins_${_library})
|
||||||
|
|
||||||
|
set(${_library_uc}_DIR ${OSGPlugins_LIB_DIR}) # to help function osg_find_library
|
||||||
|
set(_saved_lib_prefix ${CMAKE_FIND_LIBRARY_PREFIXES}) # save CMAKE_FIND_LIBRARY_PREFIXES
|
||||||
|
set(CMAKE_FIND_LIBRARY_PREFIXES "") # search libraries with no prefix
|
||||||
|
osg_find_library(${_library_uc} ${_library}) # find it into ${_library_uc}_LIBRARIES
|
||||||
|
set(CMAKE_FIND_LIBRARY_PREFIXES ${_saved_lib_prefix}) # restore prefix
|
||||||
|
|
||||||
|
if (${_library_uc}_LIBRARIES)
|
||||||
|
set(${_component}_LIBRARY ${${_library_uc}_LIBRARIES}) # fake as if we call find_library
|
||||||
|
else()
|
||||||
|
set(${_component}_LIBRARY ${_component}_LIBRARY-NOTFOUND)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND OSGPlugins_PROCESS_LIBS ${_component}_LIBRARY)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(_dependency PNG ZLIB JPEG) # needed by osgdb_png or osgdb_jpeg
|
||||||
|
libfind_package(OSGPlugins ${_dependency})
|
||||||
|
set(${_dependency}_LIBRARY_OPTS ${_dependency}_LIBRARY)
|
||||||
|
#list(APPEND OSGPlugins_PROCESS_LIBS ${_dependency}_LIBRARY)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
libfind_process(OSGPlugins)
|
|
@ -1,161 +0,0 @@
|
||||||
#-------------------------------------------------------------------
|
|
||||||
# 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.
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
##################################################################
|
|
||||||
# Provides some common functionality for the FindPackage modules
|
|
||||||
##################################################################
|
|
||||||
|
|
||||||
# Begin processing of package
|
|
||||||
macro(findpkg_begin PREFIX)
|
|
||||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
|
||||||
message(STATUS "Looking for ${PREFIX}...")
|
|
||||||
endif ()
|
|
||||||
endmacro(findpkg_begin)
|
|
||||||
|
|
||||||
# Display a status message unless FIND_QUIETLY is set
|
|
||||||
macro(pkg_message PREFIX)
|
|
||||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
|
||||||
message(STATUS ${ARGN})
|
|
||||||
endif ()
|
|
||||||
endmacro(pkg_message)
|
|
||||||
|
|
||||||
# Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
|
|
||||||
macro(getenv_path VAR)
|
|
||||||
set(ENV_${VAR} $ENV{${VAR}})
|
|
||||||
# replace won't work if var is blank
|
|
||||||
if (ENV_${VAR})
|
|
||||||
string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
|
|
||||||
endif ()
|
|
||||||
endmacro(getenv_path)
|
|
||||||
|
|
||||||
# Construct search paths for includes and libraries from a PREFIX_PATH
|
|
||||||
macro(create_search_paths PREFIX)
|
|
||||||
foreach(dir ${${PREFIX}_PREFIX_PATH})
|
|
||||||
set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
|
|
||||||
${dir}/include ${dir}/Include ${dir}/include/${PREFIX} ${dir}/Headers)
|
|
||||||
set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
|
|
||||||
${dir}/lib ${dir}/Lib ${dir}/lib/${PREFIX} ${dir}/Libs)
|
|
||||||
set(${PREFIX}_BIN_SEARCH_PATH ${${PREFIX}_BIN_SEARCH_PATH}
|
|
||||||
${dir}/bin)
|
|
||||||
endforeach(dir)
|
|
||||||
set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
|
|
||||||
endmacro(create_search_paths)
|
|
||||||
|
|
||||||
# clear cache variables if a certain variable changed
|
|
||||||
macro(clear_if_changed TESTVAR)
|
|
||||||
# test against internal check variable
|
|
||||||
# HACK: Apparently, adding a variable to the cache cleans up the list
|
|
||||||
# a bit. We need to also remove any empty strings from the list, but
|
|
||||||
# at the same time ensure that we are actually dealing with a list.
|
|
||||||
list(APPEND ${TESTVAR} "")
|
|
||||||
list(REMOVE_ITEM ${TESTVAR} "")
|
|
||||||
if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
|
|
||||||
message(STATUS "${TESTVAR} changed.")
|
|
||||||
foreach(var ${ARGN})
|
|
||||||
set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
|
|
||||||
endforeach(var)
|
|
||||||
endif ()
|
|
||||||
set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE)
|
|
||||||
endmacro(clear_if_changed)
|
|
||||||
|
|
||||||
# Try to get some hints from pkg-config, if available
|
|
||||||
macro(use_pkgconfig PREFIX PKGNAME)
|
|
||||||
find_package(PkgConfig)
|
|
||||||
if (PKG_CONFIG_FOUND)
|
|
||||||
pkg_check_modules(${PREFIX} ${PKGNAME})
|
|
||||||
endif ()
|
|
||||||
endmacro (use_pkgconfig)
|
|
||||||
|
|
||||||
# Couple a set of release AND debug libraries (or frameworks)
|
|
||||||
macro(make_library_set PREFIX)
|
|
||||||
if (${PREFIX}_FWK)
|
|
||||||
set(${PREFIX} ${${PREFIX}_FWK})
|
|
||||||
elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
|
|
||||||
set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
|
|
||||||
elseif (${PREFIX}_REL)
|
|
||||||
set(${PREFIX} ${${PREFIX}_REL})
|
|
||||||
elseif (${PREFIX}_DBG)
|
|
||||||
set(${PREFIX} ${${PREFIX}_DBG})
|
|
||||||
endif ()
|
|
||||||
endmacro(make_library_set)
|
|
||||||
|
|
||||||
# Generate debug names from given release names
|
|
||||||
macro(get_debug_names PREFIX)
|
|
||||||
foreach(i ${${PREFIX}})
|
|
||||||
set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
|
|
||||||
endforeach(i)
|
|
||||||
endmacro(get_debug_names)
|
|
||||||
|
|
||||||
# Add the parent dir from DIR to VAR
|
|
||||||
macro(add_parent_dir VAR DIR)
|
|
||||||
get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE)
|
|
||||||
set(${VAR} ${${VAR}} ${${DIR}_TEMP})
|
|
||||||
endmacro(add_parent_dir)
|
|
||||||
|
|
||||||
# Do the final processing for the package find.
|
|
||||||
macro(findpkg_finish PREFIX)
|
|
||||||
# skip if already processed during this run
|
|
||||||
if (NOT ${PREFIX}_FOUND)
|
|
||||||
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
|
|
||||||
set(${PREFIX}_FOUND TRUE)
|
|
||||||
set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
|
|
||||||
set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
|
|
||||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
|
||||||
message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
|
|
||||||
endif ()
|
|
||||||
else ()
|
|
||||||
if (NOT ${PREFIX}_FIND_QUIETLY)
|
|
||||||
message(STATUS "Could not locate ${PREFIX}")
|
|
||||||
endif ()
|
|
||||||
if (${PREFIX}_FIND_REQUIRED)
|
|
||||||
message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
|
|
||||||
endif ()
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
|
|
||||||
endif ()
|
|
||||||
endmacro(findpkg_finish)
|
|
||||||
|
|
||||||
|
|
||||||
# Slightly customised framework finder
|
|
||||||
MACRO(findpkg_framework fwk)
|
|
||||||
IF(APPLE)
|
|
||||||
SET(${fwk}_FRAMEWORK_PATH
|
|
||||||
${${fwk}_FRAMEWORK_SEARCH_PATH}
|
|
||||||
${CMAKE_FRAMEWORK_PATH}
|
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
|
||||||
/System/Library/Frameworks
|
|
||||||
/Network/Library/Frameworks
|
|
||||||
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/Release
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/lib/Debug
|
|
||||||
)
|
|
||||||
# These could be arrays of paths, add each individually to the search paths
|
|
||||||
foreach(i ${OGRE_PREFIX_PATH})
|
|
||||||
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/Release ${i}/lib/Debug)
|
|
||||||
endforeach(i)
|
|
||||||
|
|
||||||
foreach(i ${OGRE_PREFIX_BUILD})
|
|
||||||
set(${fwk}_FRAMEWORK_PATH ${${fwk}_FRAMEWORK_PATH} ${i}/lib/Release ${i}/lib/Debug)
|
|
||||||
endforeach(i)
|
|
||||||
|
|
||||||
FOREACH(dir ${${fwk}_FRAMEWORK_PATH})
|
|
||||||
SET(fwkpath ${dir}/${fwk}.framework)
|
|
||||||
IF(EXISTS ${fwkpath})
|
|
||||||
SET(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES}
|
|
||||||
${fwkpath}/Headers ${fwkpath}/PrivateHeaders)
|
|
||||||
SET(${fwk}_FRAMEWORK_PATH ${dir})
|
|
||||||
if (NOT ${fwk}_LIBRARY_FWK)
|
|
||||||
SET(${fwk}_LIBRARY_FWK "-framework ${fwk}")
|
|
||||||
endif ()
|
|
||||||
ENDIF(EXISTS ${fwkpath})
|
|
||||||
ENDFOREACH(dir)
|
|
||||||
ENDIF(APPLE)
|
|
||||||
ENDMACRO(findpkg_framework)
|
|
|
@ -1,16 +1,20 @@
|
||||||
# Locate SDL2 library
|
# Locate SDL2 library
|
||||||
# This module defines
|
# This module defines
|
||||||
# SDL2_LIBRARY, the name of the library to link against
|
# SDL2_LIBRARY, the SDL2 library, with no other libraries
|
||||||
|
# SDL2_LIBRARIES, the SDL library and required components with compiler flags
|
||||||
# SDL2_FOUND, if false, do not try to link to SDL2
|
# SDL2_FOUND, if false, do not try to link to SDL2
|
||||||
# SDL2_INCLUDE_DIR, where to find SDL.h
|
# SDL2_INCLUDE_DIR, where to find SDL.h
|
||||||
|
# SDL2_VERSION, the version of the found library
|
||||||
#
|
#
|
||||||
|
# This module accepts the following env variables
|
||||||
|
# SDL2DIR - Can be set to ./configure --prefix=$SDL2DIR used in building SDL2. l.e.galup 9-20-02
|
||||||
# This module responds to the the flag:
|
# This module responds to the the flag:
|
||||||
# SDL2_BUILDING_LIBRARY
|
# SDL2_BUILDING_LIBRARY
|
||||||
# If this is defined, then no SDL2_main will be linked in because
|
# If this is defined, then no SDL2_main will be linked in because
|
||||||
# only applications need main().
|
# only applications need main().
|
||||||
# Otherwise, it is assumed you are building an application and this
|
# Otherwise, it is assumed you are building an application and this
|
||||||
# module will attempt to locate and set the the proper link flags
|
# module will attempt to locate and set the the proper link flags
|
||||||
# as part of the returned SDL2_LIBRARY variable.
|
# as part of the returned SDL2_LIBRARIES variable.
|
||||||
#
|
#
|
||||||
# Don't forget to include SDL2main.h and SDL2main.m your project for the
|
# Don't forget to include SDL2main.h and SDL2main.m your project for the
|
||||||
# OS X framework based version. (Other versions link to -lSDL2main which
|
# OS X framework based version. (Other versions link to -lSDL2main which
|
||||||
|
@ -18,20 +22,6 @@
|
||||||
# module will automatically add the -framework Cocoa on your behalf.
|
# module will automatically add the -framework Cocoa on your behalf.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
|
|
||||||
# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
|
|
||||||
# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
|
|
||||||
# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
|
|
||||||
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
|
|
||||||
# as appropriate. These values are used to generate the final SDL2_LIBRARY
|
|
||||||
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# $SDL2DIR is an environment variable that would
|
|
||||||
# correspond to the ./configure --prefix=$SDL2DIR
|
|
||||||
# used in building SDL2.
|
|
||||||
# l.e.galup 9-20-02
|
|
||||||
#
|
|
||||||
# Modified by Eric Wing.
|
# Modified by Eric Wing.
|
||||||
# Added code to assist with automated building by using environmental variables
|
# Added code to assist with automated building by using environmental variables
|
||||||
# and providing a more controlled/consistent search behavior.
|
# and providing a more controlled/consistent search behavior.
|
||||||
|
@ -71,126 +61,69 @@
|
||||||
# License text for the above reference.)
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
|
||||||
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
HINTS
|
set(_sdl_lib_suffix lib/x64)
|
||||||
$ENV{SDL2DIR}
|
else()
|
||||||
PATH_SUFFIXES include/SDL2 include
|
set(_sdl_lib_suffix lib/x86)
|
||||||
PATHS
|
endif()
|
||||||
~/Library/Frameworks
|
|
||||||
/Library/Frameworks
|
libfind_pkg_detect(SDL2 sdl2
|
||||||
/usr/local/include/SDL2
|
FIND_PATH SDL.h
|
||||||
/usr/include/SDL2
|
HINTS $ENV{SDL2DIR}
|
||||||
/sw # Fink
|
PATH_SUFFIXES include SDL2
|
||||||
/opt/local # DarwinPorts
|
FIND_LIBRARY SDL2
|
||||||
/opt/csw # Blastwave
|
HINTS $ENV{SDL2DIR}
|
||||||
/opt
|
PATH_SUFFIXES ${_sdl_lib_suffix}
|
||||||
)
|
)
|
||||||
#MESSAGE("SDL2_INCLUDE_DIR is ${SDL2_INCLUDE_DIR}")
|
libfind_version_n_header(SDL2 NAMES SDL_version.h DEFINES SDL_MAJOR_VERSION SDL_MINOR_VERSION SDL_PATCHLEVEL)
|
||||||
|
|
||||||
FIND_LIBRARY(SDL2_LIBRARY_PATH
|
IF(NOT SDL2_BUILDING_LIBRARY AND NOT APPLE)
|
||||||
NAMES SDL2
|
|
||||||
HINTS
|
|
||||||
$ENV{SDL2DIR}
|
|
||||||
PATH_SUFFIXES lib64 lib
|
|
||||||
PATHS
|
|
||||||
/sw
|
|
||||||
/opt/local
|
|
||||||
/opt/csw
|
|
||||||
/opt
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SDL2_LIBRARY_ONLY ${SDL2_LIBRARY_PATH} CACHE STRING "The SDL2 library, with no other libraries.")
|
|
||||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_PATH})
|
|
||||||
|
|
||||||
#MESSAGE("SDL2_LIBRARY_TEMP is ${SDL2_LIBRARY_TEMP}")
|
|
||||||
|
|
||||||
IF(NOT SDL2_BUILDING_LIBRARY)
|
|
||||||
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
|
||||||
# Non-OS X framework versions expect you to also dynamically link to
|
# Non-OS X framework versions expect you to also dynamically link to
|
||||||
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||||
# seem to provide SDL2main for compatibility even though they don't
|
# seem to provide SDL2main for compatibility even though they don't
|
||||||
# necessarily need it.
|
# necessarily need it.
|
||||||
FIND_LIBRARY(SDL2MAIN_LIBRARY
|
libfind_pkg_detect(SDL2MAIN sdl2
|
||||||
NAMES SDL2main
|
FIND_LIBRARY SDL2main
|
||||||
HINTS
|
HINTS $ENV{SDL2DIR}
|
||||||
$ENV{SDL2DIR}
|
PATH_SUFFIXES ${_sdl_lib_suffix}
|
||||||
PATH_SUFFIXES lib64 lib
|
|
||||||
PATHS
|
|
||||||
/sw
|
|
||||||
/opt/local
|
|
||||||
/opt/csw
|
|
||||||
/opt
|
|
||||||
)
|
)
|
||||||
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
set(SDL2MAIN_FIND_QUIETLY TRUE)
|
||||||
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
libfind_process(SDL2MAIN)
|
||||||
|
list(APPEND SDL2_PROCESS_LIBS SDL2MAIN_LIBRARY)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
|
||||||
|
set(SDL2_TARGET_SPECIFIC)
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||||
|
list(APPEND SDL2_TARGET_SPECIFIC "-framework Cocoa")
|
||||||
|
else()
|
||||||
# SDL2 may require threads on your system.
|
# SDL2 may require threads on your system.
|
||||||
# The Apple build may not need an explicit flag because one of the
|
# The Apple build may not need an explicit flag because one of the
|
||||||
# frameworks may already provide it.
|
# frameworks may already provide it.
|
||||||
# But for non-OSX systems, I will use the CMake Threads package.
|
# But for non-OSX systems, I will use the CMake Threads package.
|
||||||
IF(NOT APPLE)
|
libfind_package(SDL2 Threads)
|
||||||
FIND_PACKAGE(Threads)
|
list(APPEND SDL2_TARGET_SPECIFIC ${CMAKE_THREAD_LIBS_INIT})
|
||||||
ENDIF(NOT APPLE)
|
endif()
|
||||||
|
|
||||||
# MinGW needs an additional library, mwindows
|
# MinGW needs an additional library, mwindows
|
||||||
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
|
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
|
||||||
# (Actually on second look, I think it only needs one of the m* libraries.)
|
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||||
IF(MINGW)
|
if(MINGW)
|
||||||
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
list(APPEND SDL2_TARGET_SPECIFIC mingw32)
|
||||||
ENDIF(MINGW)
|
endif()
|
||||||
|
|
||||||
SET(SDL2_FOUND "NO")
|
if(WIN32)
|
||||||
IF(SDL2_LIBRARY_TEMP)
|
list(APPEND SDL2_TARGET_SPECIFIC winmm imm32 version msimg32)
|
||||||
# For SDL2main
|
endif()
|
||||||
IF(NOT SDL2_BUILDING_LIBRARY)
|
|
||||||
IF(SDL2MAIN_LIBRARY)
|
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
|
||||||
ENDIF(SDL2MAIN_LIBRARY)
|
|
||||||
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
|
||||||
|
|
||||||
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
set(SDL2_PROCESS_LIBS SDL2_TARGET_SPECIFIC)
|
||||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
|
||||||
# though it actually is there if I modify a pre-used variable.
|
|
||||||
# I think it has something to do with the CACHE STRING.
|
|
||||||
# So I use a temporary variable until the end so I can set the
|
|
||||||
# "real" variable in one-shot.
|
|
||||||
IF(APPLE)
|
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
|
||||||
ENDIF(APPLE)
|
|
||||||
|
|
||||||
# For threads, as mentioned Apple doesn't need this.
|
libfind_process(SDL2)
|
||||||
# In fact, there seems to be a problem if I used the Threads package
|
|
||||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
|
||||||
IF(NOT APPLE)
|
|
||||||
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
ENDIF(NOT APPLE)
|
|
||||||
|
|
||||||
# For MinGW library
|
if (SDL2_STATIC AND UNIX AND NOT APPLE)
|
||||||
IF(MINGW)
|
execute_process(COMMAND sdl2-config --static-libs OUTPUT_VARIABLE SDL2_STATIC_FLAGS)
|
||||||
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
string(REGEX REPLACE "(\r?\n)+$" "" SDL2_STATIC_FLAGS "${SDL2_STATIC_FLAGS}")
|
||||||
ENDIF(MINGW)
|
set(SDL2_LIBRARIES ${SDL2_STATIC_FLAGS})
|
||||||
|
endif()
|
||||||
IF(WIN32)
|
|
||||||
SET(SDL2_LIBRARY_TEMP winmm imm32 version msimg32 ${SDL2_LIBRARY_TEMP})
|
|
||||||
ENDIF(WIN32)
|
|
||||||
|
|
||||||
# Set the final string here so the GUI reflects the final state.
|
|
||||||
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
|
||||||
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
|
||||||
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
|
||||||
|
|
||||||
SET(SDL2_FOUND "YES")
|
|
||||||
ENDIF(SDL2_LIBRARY_TEMP)
|
|
||||||
|
|
||||||
INCLUDE(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
|
|
||||||
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
|
||||||
|
|
||||||
IF(SDL2_STATIC)
|
|
||||||
if (UNIX AND NOT APPLE)
|
|
||||||
EXECUTE_PROCESS(COMMAND sdl2-config --static-libs OUTPUT_VARIABLE SDL2_LINK_FLAGS)
|
|
||||||
STRING(REGEX REPLACE "(\r?\n)+$" "" SDL2_LINK_FLAGS "${SDL2_LINK_FLAGS}")
|
|
||||||
SET(SDL2_LIBRARY ${SDL2_LINK_FLAGS})
|
|
||||||
ENDIF()
|
|
||||||
ENDIF(SDL2_STATIC)
|
|
||||||
|
|
|
@ -2,44 +2,36 @@
|
||||||
# Find the Sphinx documentation generator
|
# Find the Sphinx documentation generator
|
||||||
#
|
#
|
||||||
# This modules defines
|
# This modules defines
|
||||||
# SPHINX_EXECUTABLE
|
# Sphinx_EXECUTABLE
|
||||||
# SPHINX_FOUND
|
# Sphinx_FOUND
|
||||||
|
# function Sphinx_add_target
|
||||||
|
# function Sphinx_add_targets
|
||||||
|
#
|
||||||
|
|
||||||
find_program(SPHINX_EXECUTABLE
|
include(FindPackageHandleStandardArgs)
|
||||||
NAMES sphinx-build
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
|
set(_sphinx_names sphinx-build)
|
||||||
|
foreach(_version 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)
|
||||||
|
list(APPEND _sphinx_names sphinx-build-${_version})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
find_program(Sphinx_EXECUTABLE
|
||||||
|
NAMES ${_sphinx_names}
|
||||||
PATHS
|
PATHS
|
||||||
/usr/bin
|
/usr/bin
|
||||||
/usr/local/bin
|
/usr/local/bin
|
||||||
/opt/local/bin
|
/opt/local/bin
|
||||||
DOC "Sphinx documentation generator"
|
DOC "Sphinx documentation generator"
|
||||||
)
|
)
|
||||||
|
mark_as_advanced(Sphinx_EXECUTABLE)
|
||||||
|
|
||||||
if( NOT SPHINX_EXECUTABLE )
|
|
||||||
set(_Python_VERSIONS
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Sphinx
|
||||||
2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5
|
FOUND_VAR Sphinx_FOUND
|
||||||
|
REQUIRED_VARS Sphinx_EXECUTABLE
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach( _version ${_Python_VERSIONS} )
|
|
||||||
set( _sphinx_NAMES sphinx-build-${_version} )
|
|
||||||
|
|
||||||
find_program( SPHINX_EXECUTABLE
|
|
||||||
NAMES ${_sphinx_NAMES}
|
|
||||||
PATHS
|
|
||||||
/usr/bin
|
|
||||||
/usr/local/bin
|
|
||||||
/opt/loca/bin
|
|
||||||
DOC "Sphinx documentation generator"
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
|
|
||||||
find_package_handle_standard_args(Sphinx DEFAULT_MSG
|
|
||||||
SPHINX_EXECUTABLE
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON )
|
option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON )
|
||||||
option( SPHINX_DIRHTML_OUTPUT "Build HTML pages, but with a single directory per document." OFF )
|
option( SPHINX_DIRHTML_OUTPUT "Build HTML pages, but with a single directory per document." OFF )
|
||||||
option( SPHINX_HTMLHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in htmlhelp." OFF )
|
option( SPHINX_HTMLHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in htmlhelp." OFF )
|
||||||
|
@ -50,96 +42,43 @@ option( SPHINX_LATEX_OUTPUT "Build LaTeX sources that can be compiled to a PDF d
|
||||||
option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF )
|
option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF )
|
||||||
option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF )
|
option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF )
|
||||||
|
|
||||||
|
|
||||||
mark_as_advanced(
|
|
||||||
SPHINX_EXECUTABLE
|
|
||||||
SPHINX_HTML_OUTPUT
|
|
||||||
SPHINX_DIRHTML_OUTPUT
|
|
||||||
SPHINX_HTMLHELP_OUTPUT
|
|
||||||
SPHINX_QTHELP_OUTPUT
|
|
||||||
SPHINX_DEVHELP_OUTPUT
|
|
||||||
SPHINX_EPUB_OUTPUT
|
|
||||||
SPHINX_LATEX_OUTPUT
|
|
||||||
SPHINX_MAN_OUTPUT
|
|
||||||
SPHINX_TEXT_OUTPUT
|
|
||||||
)
|
|
||||||
|
|
||||||
function(Sphinx_add_target target_name builder conf source destination)
|
function(Sphinx_add_target target_name builder conf source destination)
|
||||||
add_custom_target( ${target_name} ALL
|
add_custom_target( ${target_name} ALL
|
||||||
COMMAND ${SPHINX_EXECUTABLE} -b ${builder}
|
COMMAND ${Sphinx_EXECUTABLE} -b ${builder} -c ${conf} ${source} ${destination}
|
||||||
-c ${conf}
|
DEPENDS ${conf}/conf.py
|
||||||
${source}
|
|
||||||
${destination}
|
|
||||||
COMMENT "Generating sphinx documentation: ${builder}"
|
COMMENT "Generating sphinx documentation: ${builder}"
|
||||||
)
|
)
|
||||||
|
|
||||||
set_property(
|
set_property(DIRECTORY APPEND PROPERTY
|
||||||
DIRECTORY APPEND PROPERTY
|
ADDITIONAL_MAKE_CLEAN_FILES ${destination}
|
||||||
ADDITIONAL_MAKE_CLEAN_FILES
|
|
||||||
${destination}
|
|
||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Target dependencies can be optionally listed at the end.
|
# Usage:
|
||||||
function( Sphinx_add_targets target_base_name conf source base_destination )
|
#
|
||||||
|
# Sphinx_add_targets(NAME <base_targets_name>
|
||||||
|
# SRC_DIR <path_to_doc>/
|
||||||
|
# DST_DIR <path_to_output_result>/
|
||||||
|
# CONFIG_DIR <path_to_conf.py>/
|
||||||
|
# [DEPENDENCIES dep1 dep2 dep3 ...]
|
||||||
|
# )
|
||||||
|
function(Sphinx_add_targets)
|
||||||
|
set(options )
|
||||||
|
set(one_value_keywords NAME SRC_DIR DST_DIR CONFIG_DIR)
|
||||||
|
set(multi_value_keywords DEPENDENCIES)
|
||||||
|
CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN})
|
||||||
|
|
||||||
set( _dependencies )
|
if (NOT OPT_NAME OR NOT OPT_SRC_DIR OR NOT OPT_DST_DIR OR NOT OPT_CONFIG_DIR)
|
||||||
|
message(FATAL_ERROR "Arguments NAME, SRC_DIR, DST_DIR, CONFIG_DIR are required!")
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach( arg IN LISTS ARGN )
|
foreach(_generator html dirhtml qthelp devhelp epub latex man text linkcheck)
|
||||||
set( _dependencies ${_dependencies} ${arg} )
|
string(TOUPPER ${_generator} _generator_uc)
|
||||||
|
if (SPHINX_${_generator_uc}_OUTPUT)
|
||||||
|
Sphinx_add_target(${OPT_NAME}_${_generator} ${_generator} ${OPT_CONFIG_DIR} ${OPT_SRC_DIR} ${OPT_DST_DIR}/${_generator}/)
|
||||||
|
if (OPT_DEPENDENCIES)
|
||||||
|
add_dependencies(${OPT_NAME}_${_generator} ${OPT_DEPENDENCIES})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if( ${SPHINX_HTML_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_html html ${conf} ${source} ${base_destination}/html )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_html ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${SPHINX_DIRHTML_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_dirhtml dirhtml ${conf} ${source} ${base_destination}/dirhtml )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_dirhtml ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${SPHINX_QTHELP_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_qthelp qthelp ${conf} ${source} ${base_destination}/qthelp )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_qthelp ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${SPHINX_DEVHELP_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_devhelp devhelp ${conf} ${source} ${base_destination}/devhelp )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_devhelp ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${SPHINX_EPUB_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_epub epub ${conf} ${source} ${base_destination}/epub )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_epub ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${SPHINX_LATEX_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_latex latex ${conf} ${source} ${base_destination}/latex )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_latex ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${SPHINX_MAN_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_man man ${conf} ${source} ${base_destination}/man )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_man ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${SPHINX_TEXT_OUTPUT} )
|
|
||||||
Sphinx_add_target( ${target_base_name}_text text ${conf} ${source} ${base_destination}/text )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_text ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( ${BUILD_TESTING} )
|
|
||||||
sphinx_add_target( ${target_base_name}_linkcheck linkcheck ${conf} ${source} ${base_destination}/linkcheck )
|
|
||||||
|
|
||||||
add_dependencies( ${target_base_name}_linkcheck ${_dependencies} )
|
|
||||||
endif()
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -322,7 +322,7 @@ function (libfind_process PREFIX)
|
||||||
set(val ${${i}})
|
set(val ${${i}})
|
||||||
if ("${val}" STREQUAL "${i}-NOTFOUND")
|
if ("${val}" STREQUAL "${i}-NOTFOUND")
|
||||||
set (val "<not found>")
|
set (val "<not found>")
|
||||||
elseif (val AND NOT EXISTS ${val})
|
elseif (val AND NOT EXISTS "${val}")
|
||||||
set (val "${val} (does not exist)")
|
set (val "${val} (does not exist)")
|
||||||
else()
|
else()
|
||||||
set(some_files TRUE)
|
set(some_files TRUE)
|
||||||
|
|
|
@ -868,6 +868,8 @@ namespace NifOsg
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
osg::BoundingBox box;
|
||||||
|
|
||||||
int i=0;
|
int i=0;
|
||||||
for (std::vector<Nif::NiParticleSystemController::Particle>::const_iterator it = partctrl->particles.begin();
|
for (std::vector<Nif::NiParticleSystemController::Particle>::const_iterator it = partctrl->particles.begin();
|
||||||
i<particledata->activeCount && it != partctrl->particles.end(); ++it, ++i)
|
i<particledata->activeCount && it != partctrl->particles.end(); ++it, ++i)
|
||||||
|
@ -882,7 +884,8 @@ namespace NifOsg
|
||||||
// Note this position and velocity is not correct for a particle system with absolute reference frame,
|
// Note this position and velocity is not correct for a particle system with absolute reference frame,
|
||||||
// which can not be done in this loader since we are not attached to the scene yet. Will be fixed up post-load in the SceneManager.
|
// which can not be done in this loader since we are not attached to the scene yet. Will be fixed up post-load in the SceneManager.
|
||||||
created->setVelocity(particle.velocity);
|
created->setVelocity(particle.velocity);
|
||||||
created->setPosition(particledata->vertices->at(particle.vertex));
|
const osg::Vec3f& position = particledata->vertices->at(particle.vertex);
|
||||||
|
created->setPosition(position);
|
||||||
|
|
||||||
osg::Vec4f partcolor (1.f,1.f,1.f,1.f);
|
osg::Vec4f partcolor (1.f,1.f,1.f,1.f);
|
||||||
if (particle.vertex < int(particledata->colors->size()))
|
if (particle.vertex < int(particledata->colors->size()))
|
||||||
|
@ -891,10 +894,12 @@ namespace NifOsg
|
||||||
float size = particledata->sizes.at(particle.vertex) * partctrl->size;
|
float size = particledata->sizes.at(particle.vertex) * partctrl->size;
|
||||||
|
|
||||||
created->setSizeRange(osgParticle::rangef(size, size));
|
created->setSizeRange(osgParticle::rangef(size, size));
|
||||||
|
box.expandBy(osg::BoundingSphere(position, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::BoundingBox box;
|
// radius may be used to force a larger bounding box
|
||||||
box.expandBy(osg::BoundingSphere(osg::Vec3(0,0,0), particledata->radius));
|
box.expandBy(osg::BoundingSphere(osg::Vec3(0,0,0), particledata->radius));
|
||||||
|
|
||||||
partsys->setInitialBound(box);
|
partsys->setInitialBound(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,6 @@
|
||||||
|
|
||||||
#include "resourcemanager.hpp"
|
#include "resourcemanager.hpp"
|
||||||
|
|
||||||
namespace osgViewer
|
|
||||||
{
|
|
||||||
class Viewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace osgDB
|
namespace osgDB
|
||||||
{
|
{
|
||||||
class Options;
|
class Options;
|
||||||
|
|
Loading…
Reference in a new issue