Add OpenMW commits up to 11 Jul 2020
# Conflicts: # .travis.yml # apps/openmw/mwmechanics/actors.cpppull/593/head
commit
39e429c9eb
@ -1,73 +0,0 @@
|
||||
# - Try to find the Bullet physics engine
|
||||
#
|
||||
# This module accepts the following env variables
|
||||
# BULLET_ROOT - Can be set to bullet install path or Windows build path
|
||||
#
|
||||
# Once done this will define
|
||||
# Bullet_FOUND - System has the all required components.
|
||||
# Bullet_INCLUDE_DIRS - Include directory necessary for using the required components headers.
|
||||
# Bullet_LIBRARIES - Link these to use the required bullet components.
|
||||
# Bullet_VERSION - Version of libbullet
|
||||
#
|
||||
# For each of the components
|
||||
# - LinearMath
|
||||
# - BulletCollision
|
||||
# - BulletSoftBody
|
||||
# - BulletDynamics
|
||||
#
|
||||
# Copyright (c) 2009, Philip Lowman <philip at yhbt.com>
|
||||
# Modified for OpenMW to parse BT_BULLET_VERSION.
|
||||
#
|
||||
# Redistribution AND use is allowed according to the terms of the New
|
||||
# BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
include(LibFindMacros)
|
||||
|
||||
# Macro: _internal_find_bullet_library
|
||||
# Checks for the given component by invoking pkgconfig etc.
|
||||
macro(_internal_find_bullet_library _lib)
|
||||
libfind_pkg_detect(Bullet_${_lib} bullet
|
||||
FIND_LIBRARY ${_lib}
|
||||
HINTS $ENV{BULLET_ROOT}
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
libfind_process(Bullet_${_lib})
|
||||
endmacro()
|
||||
|
||||
set(_known_components LinearMath BulletCollision BulletSoftBody BulletDynamics)
|
||||
|
||||
# Check if the required components were found and add their stuff to the Bullet_* vars.
|
||||
foreach (_component ${Bullet_FIND_COMPONENTS})
|
||||
list(FIND _known_components ${_component} _known_component)
|
||||
if (_known_component EQUAL -1)
|
||||
message(FATAL_ERROR "Unknown component '${_component}'")
|
||||
endif()
|
||||
|
||||
set(Bullet_${_component}_Debug_FIND_QUIETLY TRUE) # don't spam messages with optional Debug component
|
||||
_internal_find_bullet_library(${_component})
|
||||
_internal_find_bullet_library(${_component}_Debug)
|
||||
|
||||
if (Bullet_${_component}_Debug_FOUND)
|
||||
set(Bullet_LIBRARIES ${Bullet_LIBRARIES} optimized ${Bullet_${_component}_LIBRARIES} debug ${Bullet_${_component}_Debug_LIBRARIES})
|
||||
else()
|
||||
set(Bullet_LIBRARIES ${Bullet_LIBRARIES} ${Bullet_${_component}_LIBRARIES})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
libfind_pkg_detect(Bullet bullet
|
||||
FIND_PATH btBulletCollisionCommon.h
|
||||
HINTS $ENV{BULLET_ROOT}
|
||||
PATH_SUFFIXES include/bullet
|
||||
)
|
||||
set(Bullet_INCLUDE_DIRS ${Bullet_INCLUDE_DIR})
|
||||
libfind_version_header(Bullet LinearMath/btScalar.h BT_BULLET_VERSION)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet
|
||||
FOUND_VAR Bullet_FOUND
|
||||
VERSION_VAR Bullet_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
REQUIRED_VARS
|
||||
Bullet_LIBRARIES
|
||||
Bullet_INCLUDE_DIR
|
||||
)
|
@ -1,91 +0,0 @@
|
||||
#-------------------------------------------------------------------
|
||||
# This file is part of the CMake build system for OGRE
|
||||
# (Object-oriented Graphics Rendering Engine)
|
||||
# For the latest info, see https://www.ogre3d.org/
|
||||
#
|
||||
# The contents of this file are placed in the public domain. Feel
|
||||
# free to make use of it in any way you like.
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# - Try to find FreeType
|
||||
#
|
||||
# This module accepts the following env variable
|
||||
# FREETYPE_DIR - Can be set to custom install path
|
||||
#
|
||||
# Once done, this will define
|
||||
#
|
||||
# Freetype_FOUND - system has FreeType
|
||||
# Freetype_INCLUDE_DIRS - the FreeType include directories
|
||||
# Freetype_LIBRARIES - link these to use FreeType
|
||||
# Freetype_VERSION - version of FreeType
|
||||
#
|
||||
# libfreetype internals:
|
||||
#
|
||||
# ======================================
|
||||
# new versions (2.5.2)
|
||||
#
|
||||
# file structure:
|
||||
# <prefix>/include/freetype2/ft2build.h
|
||||
# <prefix>/include/freetype2/freetype.h
|
||||
# used as:
|
||||
# #include <ft2build.h>
|
||||
# #include <freetype.h>
|
||||
# requires:
|
||||
# -I <prefix>/include/freetype2/
|
||||
#
|
||||
# ======================================
|
||||
# old versions (2.4.8, 2.3.5)
|
||||
#
|
||||
# file structure:
|
||||
# <prefix>/include/ft2build.h
|
||||
# <prefix>/include/freetype2/freetype/freetype.h
|
||||
# used as:
|
||||
# #include <ft2build.h>
|
||||
# #include <freetype/freetype.h>
|
||||
# requires:
|
||||
# -I <prefix>/include/ -I <prefix>/include/freetype2/
|
||||
#
|
||||
# ======================================
|
||||
|
||||
include(LibFindMacros)
|
||||
|
||||
set(_REGULAR_INSTALL_PATHS
|
||||
/usr/X11R6
|
||||
/usr/local/X11R6
|
||||
/usr/local/X11
|
||||
/usr/freeware
|
||||
ENV GTKMM_BASEPATH
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
|
||||
)
|
||||
|
||||
libfind_pkg_detect(Freetype freetype2
|
||||
FIND_PATH ft2build.h
|
||||
HINTS $ENV{FREETYPE_DIR}
|
||||
PATHS ${_REGULAR_INSTALL_PATHS}
|
||||
PATH_SUFFIXES include freetype2
|
||||
FIND_LIBRARY freetype freetype2311 freetype239 freetype238 freetype235 freetype219
|
||||
HINTS $ENV{FREETYPE_DIR}
|
||||
PATHS ${_REGULAR_INSTALL_PATHS}
|
||||
PATH_SUFFIXES lib
|
||||
)
|
||||
find_path(Freetype_OLD_INCLUDE_DIR
|
||||
# in new versions of freetype old_include_dir equals to include_dir
|
||||
# see explanation above
|
||||
NAMES freetype/freetype.h freetype.h
|
||||
PATHS ${Freetype_INCLUDE_DIR}
|
||||
PATH_SUFFIXES freetype2
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
libfind_version_n_header(Freetype
|
||||
NAMES freetype/freetype.h freetype.h
|
||||
PATHS Freetype_OLD_INCLUDE_DIR
|
||||
DEFINES FREETYPE_MAJOR FREETYPE_MINOR FREETYPE_PATCH
|
||||
)
|
||||
|
||||
set(Freetype_PROCESS_INCLUDES Freetype_OLD_INCLUDE_DIR)
|
||||
libfind_process(Freetype)
|
||||
|
||||
if (Freetype_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES Freetype_INCLUDE_DIRS)
|
||||
endif()
|
@ -0,0 +1,83 @@
|
||||
#ifndef OPENMW_COMPONENTS_MISC_OBJECTPOOL_H
|
||||
#define OPENMW_COMPONENTS_MISC_OBJECTPOOL_H
|
||||
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
template <class T>
|
||||
class ObjectPool;
|
||||
|
||||
template <class T>
|
||||
class ObjectPtrDeleter
|
||||
{
|
||||
public:
|
||||
ObjectPtrDeleter(std::nullptr_t)
|
||||
: mPool(nullptr) {}
|
||||
|
||||
ObjectPtrDeleter(ObjectPool<T>& pool)
|
||||
: mPool(&pool) {}
|
||||
|
||||
void operator()(T* object) const
|
||||
{
|
||||
mPool->recycle(object);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectPool<T>* mPool;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct ObjectPtr final : std::unique_ptr<T, ObjectPtrDeleter<T>>
|
||||
{
|
||||
using std::unique_ptr<T, ObjectPtrDeleter<T>>::unique_ptr;
|
||||
using std::unique_ptr<T, ObjectPtrDeleter<T>>::operator=;
|
||||
|
||||
ObjectPtr()
|
||||
: ObjectPtr(nullptr) {}
|
||||
|
||||
ObjectPtr(std::nullptr_t)
|
||||
: std::unique_ptr<T, ObjectPtrDeleter<T>>(nullptr, nullptr) {}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class ObjectPool
|
||||
{
|
||||
friend class ObjectPtrDeleter<T>;
|
||||
|
||||
public:
|
||||
ObjectPool()
|
||||
: mObjects(std::make_unique<std::deque<T>>()) {}
|
||||
|
||||
ObjectPtr<T> get()
|
||||
{
|
||||
T* object;
|
||||
|
||||
if (!mUnused.empty())
|
||||
{
|
||||
object = mUnused.back();
|
||||
mUnused.pop_back();
|
||||
}
|
||||
else
|
||||
{
|
||||
mObjects->emplace_back();
|
||||
object = &mObjects->back();
|
||||
}
|
||||
|
||||
return ObjectPtr<T>(object, ObjectPtrDeleter<T>(*this));
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<std::deque<T>> mObjects;
|
||||
std::vector<T*> mUnused;
|
||||
|
||||
void recycle(T* object)
|
||||
{
|
||||
mUnused.push_back(object);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue