[DEV] add dynamic dependency of the bullet:linearmath and minizip
This commit is contained in:
parent
233aaf4bd5
commit
26ce81aec5
@ -9,9 +9,25 @@
|
||||
#include <etk/archive/Zip.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef ETK_BUILD_MINIZIP
|
||||
etk::archive::Zip::Zip(const std::string& _fileName) :
|
||||
etk::Archive(_fileName) {
|
||||
TK_WARNING("No archive interface (not compiled with) minizip lib");
|
||||
return;
|
||||
}
|
||||
|
||||
etk::archive::Zip::~Zip() {
|
||||
return;
|
||||
}
|
||||
|
||||
void etk::archive::Zip::loadFile(const std::map<std::string, Content>::iterator& it) {
|
||||
TK_ERROR("Can not load File with no Archive interface");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
etk::archive::Zip::Zip(const std::string& _fileName) :
|
||||
etk::Archive(_fileName),
|
||||
m_ctx(NULL) {
|
||||
m_ctx(nullptr) {
|
||||
/* Open the zip file */
|
||||
m_ctx = unzOpen(m_fileName.c_str());
|
||||
if(!m_ctx) {
|
||||
@ -108,3 +124,4 @@ void etk::archive::Zip::loadFile(const std::map<std::string, Content>::iterator&
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -10,16 +10,20 @@
|
||||
#define __ETK_ARCHIVE_ZIP_H__
|
||||
|
||||
#include <etk/archive/Archive.h>
|
||||
extern "C" {
|
||||
#include <minizip/unzip.h>
|
||||
}
|
||||
#ifdef ETK_BUILD_MINIZIP
|
||||
extern "C" {
|
||||
#include <minizip/unzip.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace etk {
|
||||
namespace archive {
|
||||
class Zip : public etk::Archive {
|
||||
private:
|
||||
unzFile m_ctx; //!< mini zip context
|
||||
unz_global_info m_info; //!< global information of the Zip
|
||||
#ifdef ETK_BUILD_MINIZIP
|
||||
private:
|
||||
unzFile m_ctx; //!< mini zip context
|
||||
unz_global_info m_info; //!< global information of the Zip
|
||||
#endif
|
||||
public:
|
||||
Zip(const std::string& _fileName);
|
||||
virtual ~Zip();
|
||||
|
@ -135,7 +135,8 @@ etk::Matrix4 etk::matLookAt(const vec3& _eye,
|
||||
{
|
||||
etk::Matrix4 tmp;
|
||||
|
||||
vec3 forward = _eye - _target;
|
||||
vec3 forward = _eye;
|
||||
forward -= _target;
|
||||
forward.safeNormalize();
|
||||
vec3 xaxis = _target.cross(_up.normalized());
|
||||
xaxis.safeNormalize();
|
||||
|
@ -6,13 +6,13 @@
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <etk/types.h>
|
||||
|
||||
#ifndef __ETK_MATH_VECTOR2D_H__
|
||||
#define __ETK_MATH_VECTOR2D_H__
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <etk/math/Vector3D.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace etk {
|
||||
|
@ -94,6 +94,7 @@ std::ostream& etk::operator <<(std::ostream& _os, const std::vector<bvec3>& _obj
|
||||
return _os;
|
||||
}
|
||||
|
||||
#ifdef __ETK_BUILD_LINEARMATH__
|
||||
vec3 quaternionToEulerXYZ(const btQuaternion& _quat) {
|
||||
// back to the euler angle :
|
||||
float xxx = _quat.x();
|
||||
@ -109,6 +110,7 @@ vec3 quaternionToEulerXYZ(const btQuaternion& _quat) {
|
||||
asin(2.0*(xxx*zzz-yyy*www)),
|
||||
atan2(2.0*(xxx*yyy + zzz*www), (xxx2-yyy2-zzz2+www2) ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace etk {
|
||||
template<> std::string to_string<vec3>(const vec3& _obj) {
|
||||
|
@ -13,10 +13,18 @@
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <math.h>
|
||||
#include <LinearMath/btScalar.h>
|
||||
#include <LinearMath/btMinMax.h>
|
||||
#include <LinearMath/btVector3.h>
|
||||
#include <LinearMath/btQuaternion.h>
|
||||
|
||||
#ifdef ETK_BUILD_LINEARMATH
|
||||
#include <LinearMath/btScalar.h>
|
||||
#include <LinearMath/btMinMax.h>
|
||||
#include <LinearMath/btVector3.h>
|
||||
#include <LinearMath/btQuaternion.h>
|
||||
#else
|
||||
namespace etk {
|
||||
template <typename T> class Vector3D;
|
||||
};
|
||||
typedef etk::Vector3D<float> btVector3;
|
||||
#endif
|
||||
|
||||
namespace etk {
|
||||
template <typename T> class Vector3D {
|
||||
@ -34,7 +42,9 @@ namespace etk {
|
||||
m_floats[2] = (T)43523424;
|
||||
m_floats[3] = (T)23452345;
|
||||
#endif
|
||||
#if (!defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs))
|
||||
#if ( !defined(__TARGET_OS__MacOs) \
|
||||
&& !defined(__TARGET_OS__IOs) \
|
||||
&& defined(ETK_BUILD_LINEARMATH))
|
||||
// hide a bullet warning
|
||||
(void)btInfinityMask;
|
||||
#endif
|
||||
@ -146,7 +156,11 @@ namespace etk {
|
||||
* @brief Return the length of the vector
|
||||
*/
|
||||
btScalar length() const {
|
||||
return btSqrt(length2());
|
||||
#ifdef ETK_BUILD_LINEARMATH
|
||||
return btSqrt(length2());
|
||||
#else
|
||||
return std::sqrt(length2());
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +202,9 @@ namespace etk {
|
||||
* @brief Return a normalized version of this vector
|
||||
*/
|
||||
Vector3D<T> normalized() const {
|
||||
return *this / length();
|
||||
Vector3D<T> out = *this;
|
||||
out /= length();
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -453,15 +469,20 @@ namespace etk {
|
||||
std::ostream& operator <<(std::ostream& _os, const btVector3& _obj);
|
||||
|
||||
// To siplify the writing of the code ==> this permit to have the same name with the glsl language...
|
||||
typedef btVector3 vec3;
|
||||
#ifdef ETK_BUILD_LINEARMATH
|
||||
typedef btVector3 vec3;
|
||||
#else
|
||||
typedef etk::Vector3D<float> vec3;
|
||||
#endif
|
||||
typedef etk::Vector3D<float> ovec3; // specific for OpenGL ... ==> never change this ...
|
||||
typedef etk::Vector3D<int32_t> ivec3;
|
||||
// not compatible with glsl ... but it is better to have a same writing
|
||||
typedef etk::Vector3D<uint32_t> uivec3;
|
||||
typedef etk::Vector3D<bool> bvec3;
|
||||
|
||||
|
||||
vec3 quaternionToEulerXYZ(const btQuaternion& quat);
|
||||
#ifdef ETK_BUILD_LINEARMATH
|
||||
vec3 quaternionToEulerXYZ(const btQuaternion& quat);
|
||||
#endif
|
||||
|
||||
inline vec3 vec3ClipInt32(const vec3& val) {
|
||||
return vec3((int32_t)val.x(), (int32_t)val.y(), (int32_t)val.z());
|
||||
|
@ -13,15 +13,18 @@
|
||||
|
||||
#include <etk/debug.h>
|
||||
#include <math.h>
|
||||
#include <LinearMath/btScalar.h>
|
||||
#include <LinearMath/btMinMax.h>
|
||||
#include <LinearMath/btVector3.h>
|
||||
#include <LinearMath/btQuaternion.h>
|
||||
|
||||
namespace etk
|
||||
{
|
||||
template <typename T> class Vector4D
|
||||
{
|
||||
#ifdef ETK_BUILD_LINEARMATH
|
||||
#include <LinearMath/btScalar.h>
|
||||
#include <LinearMath/btMinMax.h>
|
||||
#include <LinearMath/btVector3.h>
|
||||
#include <LinearMath/btQuaternion.h>
|
||||
#else
|
||||
namespace etk {
|
||||
template <typename T> class Vector4D;
|
||||
};
|
||||
#endif
|
||||
namespace etk {
|
||||
template <typename T> class Vector4D {
|
||||
public:
|
||||
T m_floats[4];
|
||||
public:
|
||||
|
@ -45,7 +45,13 @@
|
||||
#define nullptr NULL
|
||||
#endif
|
||||
|
||||
|
||||
#include <etk/stdTools.h>
|
||||
|
||||
#ifndef ETK_BUILD_LINEARMATH
|
||||
typedef float btScalar;
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
typedef float float_t;
|
||||
#endif
|
||||
|
@ -32,8 +32,8 @@ def create(target):
|
||||
myModule.add_src_file('etk/logIOs.m')
|
||||
|
||||
# name of the dependency
|
||||
myModule.add_module_depend('linearmath')
|
||||
myModule.add_module_depend('minizip')
|
||||
myModule.add_optionnal_module_depend('linearmath', "ETK_BUILD_LINEARMATH", export=True)
|
||||
myModule.add_optionnal_module_depend('minizip', "ETK_BUILD_MINIZIP")
|
||||
|
||||
if target.config["mode"] == "release":
|
||||
# TODO : The other way is to remove this ...
|
||||
|
Loading…
Reference in New Issue
Block a user