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