Add OpenMW commits up to 20 Mar 2021
# Conflicts: # apps/openmw/CMakeLists.txt # apps/openmw/mwmechanics/aipursue.cpp # components/CMakeLists.txtpull/593/head
commit
59cb31e0a7
@ -1,13 +1,19 @@
|
||||
#!/bin/sh -e
|
||||
#!/bin/sh -ex
|
||||
|
||||
# workaround python issue on travis
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew uninstall --ignore-dependencies python@3.8 || true
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew uninstall --ignore-dependencies python@3.9 || true
|
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew uninstall --ignore-dependencies qt@6 || true
|
||||
|
||||
# Some of these tools can come from places other than brew, so check before installing
|
||||
command -v ccache >/dev/null 2>&1 || brew install ccache
|
||||
command -v cmake >/dev/null 2>&1 || brew install cmake
|
||||
command -v qmake >/dev/null 2>&1 || brew install qt
|
||||
command -v qmake >/dev/null 2>&1 || brew install qt@5
|
||||
export PATH="/usr/local/opt/qt@5/bin:$PATH" # needed to use qmake in none default path as qt now points to qt6
|
||||
|
||||
ccache --version
|
||||
cmake --version
|
||||
qmake --version
|
||||
|
||||
curl -fSL -R -J https://downloads.openmw.org/osx/dependencies/openmw-deps-f8918dd.zip -o ~/openmw-deps.zip
|
||||
unzip -o ~/openmw-deps.zip -d /private/tmp/openmw-deps > /dev/null
|
||||
|
@ -0,0 +1,211 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
# Copyright 2021 Bret Curtis for OpenMW
|
||||
#[=======================================================================[.rst:
|
||||
FindRecastNavigation
|
||||
-------
|
||||
|
||||
Find the RecastNavigation include directory and library.
|
||||
|
||||
Use this module by invoking find_package with the form::
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
find_package(RecastNavigation
|
||||
[version] # Minimum version e.g. 1.8.0
|
||||
[REQUIRED] # Fail with error if RECAST is not found
|
||||
)
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
.. variable:: RecastNavigation::Recast
|
||||
|
||||
Imported target for using the RECAST library, if found.
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. variable:: RECAST_FOUND
|
||||
|
||||
Set to true if RECAST library found, otherwise false or undefined.
|
||||
|
||||
.. variable:: RECAST_INCLUDE_DIRS
|
||||
|
||||
Paths to include directories listed in one variable for use by RECAST client.
|
||||
|
||||
.. variable:: RECAST_LIBRARIES
|
||||
|
||||
Paths to libraries to linked against to use RECAST.
|
||||
|
||||
.. variable:: RECAST_VERSION
|
||||
|
||||
The version string of RECAST found.
|
||||
|
||||
Cache variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
For users who wish to edit and control the module behavior, this module
|
||||
reads hints about search locations from the following variables::
|
||||
|
||||
.. variable:: RECAST_INCLUDE_DIR
|
||||
|
||||
Path to RECAST include directory with ``Recast.h`` header.
|
||||
|
||||
.. variable:: RECAST_LIBRARY
|
||||
|
||||
Path to RECAST library to be linked.
|
||||
|
||||
NOTE: The variables above should not usually be used in CMakeLists.txt files!
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
### Find libraries ##############################################################
|
||||
|
||||
if(NOT RECAST_LIBRARY)
|
||||
find_library(RECAST_LIBRARY_RELEASE NAMES Recast HINTS ${RECASTNAVIGATION_ROOT} PATH_SUFFIXES lib)
|
||||
find_library(RECAST_LIBRARY_DEBUG NAMES Recast-d HINTS ${RECASTNAVIGATION_ROOT} PATH_SUFFIXES lib)
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(RECAST)
|
||||
mark_as_advanced(RECAST_LIBRARY_RELEASE RECAST_LIBRARY_DEBUG)
|
||||
else()
|
||||
file(TO_CMAKE_PATH "${RECAST_LIBRARY}" RECAST_LIBRARY)
|
||||
endif()
|
||||
|
||||
if(NOT DETOUR_LIBRARY)
|
||||
find_library(DETOUR_LIBRARY_RELEASE NAMES Detour HINTS ${RECASTNAVIGATION_ROOT} PATH_SUFFIXES lib)
|
||||
find_library(DETOUR_LIBRARY_DEBUG NAMES Detour-d HINTS ${RECASTNAVIGATION_ROOT} PATH_SUFFIXES lib)
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(DETOUR)
|
||||
mark_as_advanced(DETOUR_LIBRARY_RELEASE DETOUR_LIBRARY_DEBUG)
|
||||
else()
|
||||
file(TO_CMAKE_PATH "${DETOUR_LIBRARY}" DETOUR_LIBRARY)
|
||||
endif()
|
||||
|
||||
if(NOT DEBUGUTILS_LIBRARY)
|
||||
find_library(DEBUGUTILS_LIBRARY_RELEASE NAMES DebugUtils HINTS ${RECASTNAVIGATION_ROOT} PATH_SUFFIXES lib)
|
||||
find_library(DEBUGUTILS_LIBRARY_DEBUG NAMES DebugUtils-d HINTS ${RECASTNAVIGATION_ROOT} PATH_SUFFIXES lib)
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(DEBUGUTILS)
|
||||
mark_as_advanced(DEBUGUTILS_LIBRARY_RELEASE DEBUGUTILS_LIBRARY_DEBUG)
|
||||
else()
|
||||
file(TO_CMAKE_PATH "${DEBUGUTILS_LIBRARY}" DEBUGUTILS_LIBRARY)
|
||||
endif()
|
||||
|
||||
### Find include directory ####################################################
|
||||
find_path(RECAST_INCLUDE_DIR NAMES Recast.h HINTS ${RECASTNAVIGATION_ROOT} PATH_SUFFIXES include RECAST include/recastnavigation)
|
||||
mark_as_advanced(RECAST_INCLUDE_DIR)
|
||||
|
||||
if(RECAST_INCLUDE_DIR AND EXISTS "${RECAST_INCLUDE_DIR}/Recast.h")
|
||||
file(STRINGS "${RECAST_INCLUDE_DIR}/Recast.h" _Recast_h_contents
|
||||
REGEX "#define RECAST_VERSION_[A-Z]+[ ]+[0-9]+")
|
||||
string(REGEX REPLACE "#define RECAST_VERSION_MAJOR[ ]+([0-9]+).+" "\\1"
|
||||
RECAST_VERSION_MAJOR "${_Recast_h_contents}")
|
||||
string(REGEX REPLACE ".+#define RECAST_VERSION_MINOR[ ]+([0-9]+).+" "\\1"
|
||||
RECAST_VERSION_MINOR "${_Recast_h_contents}")
|
||||
string(REGEX REPLACE ".+#define RECAST_VERSION_RELEASE[ ]+([0-9]+).*" "\\1"
|
||||
RECAST_VERSION_RELEASE "${_Recast_h_contents}")
|
||||
set(RECAST_VERSION "${RECAST_VERSION_MAJOR}.${RECAST_VERSION_MINOR}.${RECAST_VERSION_RELEASE}")
|
||||
unset(_Recast_h_contents)
|
||||
endif()
|
||||
|
||||
#TODO: they don't include a version yet
|
||||
set(RECAST_VERSION "1.5.1")
|
||||
|
||||
### Set result variables ######################################################
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(RecastNavigation DEFAULT_MSG
|
||||
RECAST_LIBRARY RECAST_INCLUDE_DIR RECAST_VERSION)
|
||||
|
||||
set(RECAST_LIBRARIES ${RECAST_LIBRARY})
|
||||
set(RECAST_INCLUDE_DIRS ${RECAST_INCLUDE_DIR})
|
||||
|
||||
set(DETOUR_LIBRARIES ${DETOUR_LIBRARY})
|
||||
set(DETOUR_INCLUDE_DIRS ${RECAST_INCLUDE_DIR})
|
||||
|
||||
set(DEBUGUTILS_LIBRARIES ${DEBUGUTILS_LIBRARY})
|
||||
set(DEBUGUTILS_INCLUDE_DIRS ${RECAST_INCLUDE_DIR})
|
||||
|
||||
### Import targets ############################################################
|
||||
if(RecastNavigation_FOUND)
|
||||
if(NOT TARGET RecastNavigation::Recast)
|
||||
add_library(RecastNavigation::Recast UNKNOWN IMPORTED)
|
||||
set_target_properties(RecastNavigation::Recast PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${RECAST_INCLUDE_DIR}")
|
||||
|
||||
if(RECAST_LIBRARY_RELEASE)
|
||||
set_property(TARGET RecastNavigation::Recast APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(RecastNavigation::Recast PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${RECAST_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(RECAST_LIBRARY_DEBUG)
|
||||
set_property(TARGET RecastNavigation::Recast APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(RecastNavigation::Recast PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${RECAST_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
|
||||
if(NOT RECAST_LIBRARY_RELEASE AND NOT RECAST_LIBRARY_DEBUG)
|
||||
set_property(TARGET RecastNavigation::Recast APPEND PROPERTY
|
||||
IMPORTED_LOCATION "${RECAST_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET RecastNavigation::Detour)
|
||||
add_library(RecastNavigation::Detour UNKNOWN IMPORTED)
|
||||
set_target_properties(RecastNavigation::Detour PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${DETOUR_INCLUDE_DIR}")
|
||||
|
||||
if(DETOUR_LIBRARY_RELEASE)
|
||||
set_property(TARGET RecastNavigation::Detour APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(RecastNavigation::Detour PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${DETOUR_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(DETOUR_LIBRARY_DEBUG)
|
||||
set_property(TARGET RecastNavigation::Detour APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(RecastNavigation::Detour PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${DETOUR_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
|
||||
if(NOT DETOUR_LIBRARY_RELEASE AND NOT DETOUR_LIBRARY_DEBUG)
|
||||
set_property(TARGET RecastNavigation::Detour APPEND PROPERTY
|
||||
IMPORTED_LOCATION "${DETOUR_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET RecastNavigation::DebugUtils)
|
||||
add_library(RecastNavigation::DebugUtils UNKNOWN IMPORTED)
|
||||
set_target_properties(RecastNavigation::DebugUtils PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${DEBUGUTILS_INCLUDE_DIR}")
|
||||
|
||||
if(DEBUGUTILS_LIBRARY_RELEASE)
|
||||
set_property(TARGET RecastNavigation::DebugUtils APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(RecastNavigation::DebugUtils PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${DEBUGUTILS_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(DEBUGUTILS_LIBRARY_DEBUG)
|
||||
set_property(TARGET RecastNavigation::DebugUtils APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(RecastNavigation::DebugUtils PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${DEBUGUTILS_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
|
||||
if(NOT DEBUGUTILS_LIBRARY_RELEASE AND NOT DEBUGUTILS_LIBRARY_DEBUG)
|
||||
set_property(TARGET RecastNavigation::DebugUtils APPEND PROPERTY
|
||||
IMPORTED_LOCATION "${DEBUGUTILS_LIBRARY}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
@ -0,0 +1,44 @@
|
||||
#include "raycast.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "findsmoothpath.hpp"
|
||||
|
||||
#include <DetourCommon.h>
|
||||
#include <DetourNavMesh.h>
|
||||
#include <DetourNavMeshQuery.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
std::optional<osg::Vec3f> raycast(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents,
|
||||
const osg::Vec3f& start, const osg::Vec3f& end, const Flags includeFlags, const Settings& settings)
|
||||
{
|
||||
dtNavMeshQuery navMeshQuery;
|
||||
if (!initNavMeshQuery(navMeshQuery, navMesh, settings.mMaxNavMeshQueryNodes))
|
||||
return {};
|
||||
|
||||
dtQueryFilter queryFilter;
|
||||
queryFilter.setIncludeFlags(includeFlags);
|
||||
|
||||
dtPolyRef ref = 0;
|
||||
if (dtStatus status = navMeshQuery.findNearestPoly(start.ptr(), halfExtents.ptr(), &queryFilter, &ref, nullptr);
|
||||
dtStatusFailed(status) || ref == 0)
|
||||
return {};
|
||||
|
||||
const unsigned options = 0;
|
||||
std::array<dtPolyRef, 16> path;
|
||||
dtRaycastHit hit;
|
||||
hit.path = path.data();
|
||||
hit.maxPath = path.size();
|
||||
if (dtStatus status = navMeshQuery.raycast(ref, start.ptr(), end.ptr(), &queryFilter, options, &hit);
|
||||
dtStatusFailed(status) || hit.pathCount == 0)
|
||||
return {};
|
||||
|
||||
osg::Vec3f hitPosition;
|
||||
if (dtStatus status = navMeshQuery.closestPointOnPoly(path[hit.pathCount - 1], end.ptr(), hitPosition.ptr(), nullptr);
|
||||
dtStatusFailed(status))
|
||||
return {};
|
||||
|
||||
return hitPosition;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RAYCAST_H
|
||||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RAYCAST_H
|
||||
|
||||
#include "flags.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <osg/Vec3f>
|
||||
|
||||
class dtNavMesh;
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
struct Settings;
|
||||
|
||||
std::optional<osg::Vec3f> raycast(const dtNavMesh& navMesh, const osg::Vec3f& halfExtents,
|
||||
const osg::Vec3f& start, const osg::Vec3f& end, const Flags includeFlags, const Settings& settings);
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,12 @@
|
||||
#ifndef OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H
|
||||
#define OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H
|
||||
|
||||
#include <MyGUI_Prerequest.h>
|
||||
|
||||
#if MYGUI_VERSION > MYGUI_DEFINE_VERSION(3, 4, 0)
|
||||
#define OPENMW_MYGUI_CONST_GETTER_3_4_1 const
|
||||
#else
|
||||
#define OPENMW_MYGUI_CONST_GETTER_3_4_1
|
||||
#endif
|
||||
|
||||
#endif // OPENMW_COMPONENTS_MYGUIPLATFORM_MYGUICOMPAT_H
|
@ -0,0 +1,36 @@
|
||||
// EGL does not work reliably for feature detection.
|
||||
// Instead, we initialize gl4es manually.
|
||||
#ifdef OPENMW_GL4ES_MANUAL_INIT
|
||||
#include "gl4es_init.h"
|
||||
|
||||
// For glHint
|
||||
#include <GL/gl.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include <gl4es/gl4esinit.h>
|
||||
#include <gl4es/gl4eshint.h>
|
||||
|
||||
static SDL_Window *gWindow;
|
||||
|
||||
void openmw_gl4es_GetMainFBSize(int *width, int *height)
|
||||
{
|
||||
SDL_GetWindowSize(gWindow, width, height);
|
||||
}
|
||||
|
||||
void openmw_gl4es_init(SDL_Window *window)
|
||||
{
|
||||
gWindow = window;
|
||||
set_getprocaddress(SDL_GL_GetProcAddress);
|
||||
set_getmainfbsize(openmw_gl4es_GetMainFBSize);
|
||||
initialize_gl4es();
|
||||
|
||||
// merge glBegin/glEnd in beams and console
|
||||
glHint(GL_BEGINEND_HINT_GL4ES, 1);
|
||||
// dxt unpacked to 16-bit looks ugly
|
||||
glHint(GL_AVOID16BITS_HINT_GL4ES, 1);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // OPENMW_GL4ES_MANUAL_INIT
|
@ -0,0 +1,13 @@
|
||||
#ifndef OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
|
||||
#define OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
|
||||
#ifdef OPENMW_GL4ES_MANUAL_INIT
|
||||
#include <SDL_video.h>
|
||||
|
||||
// Must be called once SDL video mode has been set,
|
||||
// which creates a context.
|
||||
//
|
||||
// GL4ES can then query the context for features and extensions.
|
||||
extern "C" void openmw_gl4es_init(SDL_Window *window);
|
||||
|
||||
#endif // OPENMW_GL4ES_MANUAL_INIT
|
||||
#endif // OPENMW_COMPONENTS_SDLUTIL_GL4ES_INIT_H
|
@ -0,0 +1,20 @@
|
||||
#include "removedalphafunc.hpp"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <osg/State>
|
||||
|
||||
namespace Shader
|
||||
{
|
||||
std::array<osg::ref_ptr<RemovedAlphaFunc>, GL_ALWAYS - GL_NEVER + 1> RemovedAlphaFunc::sInstances{
|
||||
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr
|
||||
};
|
||||
|
||||
osg::ref_ptr<RemovedAlphaFunc> RemovedAlphaFunc::getInstance(GLenum func)
|
||||
{
|
||||
assert(func >= GL_NEVER && func <= GL_ALWAYS);
|
||||
if (!sInstances[func - GL_NEVER])
|
||||
sInstances[func - GL_NEVER] = new RemovedAlphaFunc(static_cast<osg::AlphaFunc::ComparisonFunction>(func), 1.0);
|
||||
return sInstances[func - GL_NEVER];
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
#ifndef OPENMW_COMPONENTS_REMOVEDALPHAFUNC_H
|
||||
#define OPENMW_COMPONENTS_REMOVEDALPHAFUNC_H
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <osg/AlphaFunc>
|
||||
|
||||
namespace Shader
|
||||
{
|
||||
// State attribute used when shader visitor replaces the deprecated alpha function with a shader
|
||||
// Prevents redundant glAlphaFunc calls and lets the shadowsbin know the stateset had alpha testing
|
||||
class RemovedAlphaFunc : public osg::AlphaFunc
|
||||
{
|
||||
public:
|
||||
// Get a singleton-like instance with the right func (but a default threshold)
|
||||
static osg::ref_ptr<RemovedAlphaFunc> getInstance(GLenum func);
|
||||
|
||||
RemovedAlphaFunc()
|
||||
: osg::AlphaFunc()
|
||||
{}
|
||||
|
||||
RemovedAlphaFunc(ComparisonFunction func, float ref)
|
||||
: osg::AlphaFunc(func, ref)
|
||||
{}
|
||||
|
||||
RemovedAlphaFunc(const RemovedAlphaFunc& raf, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY)
|
||||
: osg::AlphaFunc(raf, copyop)
|
||||
{}
|
||||
|
||||
META_StateAttribute(Shader, RemovedAlphaFunc, ALPHAFUNC);
|
||||
|
||||
void apply(osg::State& state) const override {}
|
||||
|
||||
protected:
|
||||
virtual ~RemovedAlphaFunc() = default;
|
||||
|
||||
static std::array<osg::ref_ptr<RemovedAlphaFunc>, GL_ALWAYS - GL_NEVER + 1> sInstances;
|
||||
};
|
||||
}
|
||||
#endif //OPENMW_COMPONENTS_REMOVEDALPHAFUNC_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue