Merge branch 'master' into fix-simpletextureddirectx11-sample2
commit
0904e4880b
|
@ -589,7 +589,7 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS )
|
||||||
ADD_SUBDIRECTORY( tools/assimp_view/ )
|
ADD_SUBDIRECTORY( tools/assimp_view/ )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
# Te command line tool
|
# The command line tool
|
||||||
ADD_SUBDIRECTORY( tools/assimp_cmd/ )
|
ADD_SUBDIRECTORY( tools/assimp_cmd/ )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
|
|
@ -185,8 +185,6 @@ SET( Common_SRCS
|
||||||
Common/ScenePreprocessor.cpp
|
Common/ScenePreprocessor.cpp
|
||||||
Common/ScenePreprocessor.h
|
Common/ScenePreprocessor.h
|
||||||
Common/SkeletonMeshBuilder.cpp
|
Common/SkeletonMeshBuilder.cpp
|
||||||
Common/SplitByBoneCountProcess.cpp
|
|
||||||
Common/SplitByBoneCountProcess.h
|
|
||||||
Common/StandardShapes.cpp
|
Common/StandardShapes.cpp
|
||||||
Common/TargetAnimation.cpp
|
Common/TargetAnimation.cpp
|
||||||
Common/TargetAnimation.h
|
Common/TargetAnimation.h
|
||||||
|
@ -737,6 +735,8 @@ SET( PostProcessing_SRCS
|
||||||
PostProcessing/ArmaturePopulate.h
|
PostProcessing/ArmaturePopulate.h
|
||||||
PostProcessing/GenBoundingBoxesProcess.cpp
|
PostProcessing/GenBoundingBoxesProcess.cpp
|
||||||
PostProcessing/GenBoundingBoxesProcess.h
|
PostProcessing/GenBoundingBoxesProcess.h
|
||||||
|
PostProcessing/SplitByBoneCountProcess.cpp
|
||||||
|
PostProcessing/SplitByBoneCountProcess.h
|
||||||
)
|
)
|
||||||
SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS})
|
SOURCE_GROUP( PostProcessing FILES ${PostProcessing_SRCS})
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -43,45 +41,43 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
/** @file Implementation of BaseProcess */
|
/** @file Implementation of BaseProcess */
|
||||||
|
|
||||||
#include <assimp/BaseImporter.h>
|
|
||||||
#include "BaseProcess.h"
|
#include "BaseProcess.h"
|
||||||
#include <assimp/DefaultLogger.hpp>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include "Importer.h"
|
#include "Importer.h"
|
||||||
|
#include <assimp/BaseImporter.h>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/DefaultLogger.hpp>
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
BaseProcess::BaseProcess() AI_NO_EXCEPT
|
BaseProcess::BaseProcess() AI_NO_EXCEPT
|
||||||
: shared()
|
: shared(),
|
||||||
, progress()
|
progress() {
|
||||||
{
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
BaseProcess::~BaseProcess()
|
BaseProcess::~BaseProcess() {
|
||||||
{
|
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void BaseProcess::ExecuteOnScene( Importer* pImp)
|
void BaseProcess::ExecuteOnScene(Importer *pImp) {
|
||||||
{
|
ai_assert( nullptr != pImp );
|
||||||
ai_assert(NULL != pImp && NULL != pImp->Pimpl()->mScene);
|
ai_assert( nullptr != pImp->Pimpl()->mScene);
|
||||||
|
|
||||||
progress = pImp->GetProgressHandler();
|
progress = pImp->GetProgressHandler();
|
||||||
ai_assert(progress);
|
ai_assert(nullptr != progress);
|
||||||
|
|
||||||
SetupProperties( pImp );
|
SetupProperties(pImp);
|
||||||
|
|
||||||
// catch exceptions thrown inside the PostProcess-Step
|
// catch exceptions thrown inside the PostProcess-Step
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
Execute(pImp->Pimpl()->mScene);
|
Execute(pImp->Pimpl()->mScene);
|
||||||
|
|
||||||
} catch( const std::exception& err ) {
|
} catch (const std::exception &err) {
|
||||||
|
|
||||||
// extract error description
|
// extract error description
|
||||||
pImp->Pimpl()->mErrorString = err.what();
|
pImp->Pimpl()->mErrorString = err.what();
|
||||||
|
@ -94,14 +90,11 @@ void BaseProcess::ExecuteOnScene( Importer* pImp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void BaseProcess::SetupProperties(const Importer* /*pImp*/)
|
void BaseProcess::SetupProperties(const Importer * /*pImp*/) {
|
||||||
{
|
|
||||||
// the default implementation does nothing
|
// the default implementation does nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool BaseProcess::RequireVerboseFormat() const
|
bool BaseProcess::RequireVerboseFormat() const {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -44,12 +43,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef INCLUDED_AI_BASEPROCESS_H
|
#ifndef INCLUDED_AI_BASEPROCESS_H
|
||||||
#define INCLUDED_AI_BASEPROCESS_H
|
#define INCLUDED_AI_BASEPROCESS_H
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <assimp/GenericProperty.h>
|
#include <assimp/GenericProperty.h>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
struct aiScene;
|
struct aiScene;
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
class Importer;
|
class Importer;
|
||||||
|
|
||||||
|
@ -60,64 +60,50 @@ class Importer;
|
||||||
* to provide additional information to other steps. This is primarily
|
* to provide additional information to other steps. This is primarily
|
||||||
* intended for cross-step optimizations.
|
* intended for cross-step optimizations.
|
||||||
*/
|
*/
|
||||||
class SharedPostProcessInfo
|
class SharedPostProcessInfo {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
struct Base {
|
||||||
struct Base
|
virtual ~Base() {}
|
||||||
{
|
|
||||||
virtual ~Base()
|
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Represents data that is allocated on the heap, thus needs to be deleted
|
//! Represents data that is allocated on the heap, thus needs to be deleted
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct THeapData : public Base
|
struct THeapData : public Base {
|
||||||
{
|
explicit THeapData(T *in) :
|
||||||
explicit THeapData(T* in)
|
data(in) {}
|
||||||
: data (in)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~THeapData()
|
~THeapData() {
|
||||||
{
|
|
||||||
delete data;
|
delete data;
|
||||||
}
|
}
|
||||||
T* data;
|
T *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Represents static, by-value data not allocated on the heap
|
//! Represents static, by-value data not allocated on the heap
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct TStaticData : public Base
|
struct TStaticData : public Base {
|
||||||
{
|
explicit TStaticData(T in) :
|
||||||
explicit TStaticData(T in)
|
data(in) {}
|
||||||
: data (in)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~TStaticData()
|
~TStaticData() {}
|
||||||
{}
|
|
||||||
|
|
||||||
T data;
|
T data;
|
||||||
};
|
};
|
||||||
|
|
||||||
// some typedefs for cleaner code
|
// some typedefs for cleaner code
|
||||||
typedef unsigned int KeyType;
|
typedef unsigned int KeyType;
|
||||||
typedef std::map<KeyType, Base*> PropertyMap;
|
typedef std::map<KeyType, Base *> PropertyMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~SharedPostProcessInfo()
|
~SharedPostProcessInfo() {
|
||||||
{
|
|
||||||
Clean();
|
Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Remove all stored properties from the table
|
//! Remove all stored properties from the table
|
||||||
void Clean()
|
void Clean() {
|
||||||
{
|
|
||||||
// invoke the virtual destructor for all stored properties
|
// invoke the virtual destructor for all stored properties
|
||||||
for (PropertyMap::iterator it = pmap.begin(), end = pmap.end();
|
for (PropertyMap::iterator it = pmap.begin(), end = pmap.end();
|
||||||
it != end; ++it)
|
it != end; ++it) {
|
||||||
{
|
|
||||||
delete (*it).second;
|
delete (*it).second;
|
||||||
}
|
}
|
||||||
pmap.clear();
|
pmap.clear();
|
||||||
|
@ -125,24 +111,21 @@ public:
|
||||||
|
|
||||||
//! Add a heap property to the list
|
//! Add a heap property to the list
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddProperty( const char* name, T* in ){
|
void AddProperty(const char *name, T *in) {
|
||||||
AddProperty(name,(Base*)new THeapData<T>(in));
|
AddProperty(name, (Base *)new THeapData<T>(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Add a static by-value property to the list
|
//! Add a static by-value property to the list
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddProperty( const char* name, T in ){
|
void AddProperty(const char *name, T in) {
|
||||||
AddProperty(name,(Base*)new TStaticData<T>(in));
|
AddProperty(name, (Base *)new TStaticData<T>(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Get a heap property
|
//! Get a heap property
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool GetProperty( const char* name, T*& out ) const
|
bool GetProperty(const char *name, T *&out) const {
|
||||||
{
|
THeapData<T> *t = (THeapData<T> *)GetPropertyInternal(name);
|
||||||
THeapData<T>* t = (THeapData<T>*)GetPropertyInternal(name);
|
if (!t) {
|
||||||
if(!t)
|
|
||||||
{
|
|
||||||
out = NULL;
|
out = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -152,53 +135,34 @@ public:
|
||||||
|
|
||||||
//! Get a static, by-value property
|
//! Get a static, by-value property
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool GetProperty( const char* name, T& out ) const
|
bool GetProperty(const char *name, T &out) const {
|
||||||
{
|
TStaticData<T> *t = (TStaticData<T> *)GetPropertyInternal(name);
|
||||||
TStaticData<T>* t = (TStaticData<T>*)GetPropertyInternal(name);
|
if ( nullptr == t) {
|
||||||
if(!t)return false;
|
return false;
|
||||||
|
}
|
||||||
out = t->data;
|
out = t->data;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Remove a property of a specific type
|
//! Remove a property of a specific type
|
||||||
void RemoveProperty( const char* name) {
|
void RemoveProperty(const char *name) {
|
||||||
SetGenericPropertyPtr<Base>(pmap,name,NULL);
|
SetGenericPropertyPtr<Base>(pmap, name, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void AddProperty(const char *name, Base *data) {
|
||||||
void AddProperty( const char* name, Base* data) {
|
SetGenericPropertyPtr<Base>(pmap, name, data);
|
||||||
SetGenericPropertyPtr<Base>(pmap,name,data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Base* GetPropertyInternal( const char* name) const {
|
Base *GetPropertyInternal(const char *name) const {
|
||||||
return GetGenericProperty<Base*>(pmap,name,NULL);
|
return GetGenericProperty<Base *>(pmap, name, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Map of all stored properties
|
//! Map of all stored properties
|
||||||
PropertyMap pmap;
|
PropertyMap pmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
/** @brief Represents a dependency table for a postprocessing steps.
|
|
||||||
*
|
|
||||||
* For future use.
|
|
||||||
*/
|
|
||||||
struct PPDependencyTable
|
|
||||||
{
|
|
||||||
unsigned int execute_me_before_these;
|
|
||||||
unsigned int execute_me_after_these;
|
|
||||||
unsigned int only_if_these_are_not_specified;
|
|
||||||
unsigned int mutually_exclusive_with;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define AI_SPP_SPATIAL_SORT "$Spat"
|
#define AI_SPP_SPATIAL_SORT "$Spat"
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -228,7 +192,7 @@ public:
|
||||||
* @return true if the process is present in this flag fields,
|
* @return true if the process is present in this flag fields,
|
||||||
* false if not.
|
* false if not.
|
||||||
*/
|
*/
|
||||||
virtual bool IsActive( unsigned int pFlags) const = 0;
|
virtual bool IsActive(unsigned int pFlags) const = 0;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Check whether this step expects its input vertex data to be
|
/** Check whether this step expects its input vertex data to be
|
||||||
|
@ -241,14 +205,14 @@ public:
|
||||||
* the object pointer will be set to NULL).
|
* the object pointer will be set to NULL).
|
||||||
* @param pImp Importer instance (pImp->mScene must be valid)
|
* @param pImp Importer instance (pImp->mScene must be valid)
|
||||||
*/
|
*/
|
||||||
void ExecuteOnScene( Importer* pImp);
|
void ExecuteOnScene(Importer *pImp);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Called prior to ExecuteOnScene().
|
/** Called prior to ExecuteOnScene().
|
||||||
* The function is a request to the process to update its configuration
|
* The function is a request to the process to update its configuration
|
||||||
* basing on the Importer's configuration property list.
|
* basing on the Importer's configuration property list.
|
||||||
*/
|
*/
|
||||||
virtual void SetupProperties(const Importer* pImp);
|
virtual void SetupProperties(const Importer *pImp);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Executes the post processing step on the given imported data.
|
/** Executes the post processing step on the given imported data.
|
||||||
|
@ -256,35 +220,32 @@ public:
|
||||||
* This method must be implemented by deriving classes.
|
* This method must be implemented by deriving classes.
|
||||||
* @param pScene The imported data to work at.
|
* @param pScene The imported data to work at.
|
||||||
*/
|
*/
|
||||||
virtual void Execute( aiScene* pScene) = 0;
|
virtual void Execute(aiScene *pScene) = 0;
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Assign a new SharedPostProcessInfo to the step. This object
|
/** Assign a new SharedPostProcessInfo to the step. This object
|
||||||
* allows multiple postprocess steps to share data.
|
* allows multiple postprocess steps to share data.
|
||||||
* @param sh May be NULL
|
* @param sh May be NULL
|
||||||
*/
|
*/
|
||||||
inline void SetSharedData(SharedPostProcessInfo* sh) {
|
inline void SetSharedData(SharedPostProcessInfo *sh) {
|
||||||
shared = sh;
|
shared = sh;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
/** Get the shared data that is assigned to the step.
|
/** Get the shared data that is assigned to the step.
|
||||||
*/
|
*/
|
||||||
inline SharedPostProcessInfo* GetSharedData() {
|
inline SharedPostProcessInfo *GetSharedData() {
|
||||||
return shared;
|
return shared;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/** See the doc of #SharedPostProcessInfo for more details */
|
/** See the doc of #SharedPostProcessInfo for more details */
|
||||||
SharedPostProcessInfo* shared;
|
SharedPostProcessInfo *shared;
|
||||||
|
|
||||||
/** Currently active progress handler */
|
/** Currently active progress handler */
|
||||||
ProgressHandler* progress;
|
ProgressHandler *progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
#endif // AI_BASEPROCESS_H_INC
|
#endif // AI_BASEPROCESS_H_INC
|
||||||
|
|
|
@ -123,7 +123,7 @@ corresponding preprocessor flag to selectively disable steps.
|
||||||
# include "PostProcessing/OptimizeGraph.h"
|
# include "PostProcessing/OptimizeGraph.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS
|
#ifndef ASSIMP_BUILD_NO_SPLITBYBONECOUNT_PROCESS
|
||||||
# include "Common/SplitByBoneCountProcess.h"
|
# include "PostProcessing/SplitByBoneCountProcess.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef ASSIMP_BUILD_NO_DEBONE_PROCESS
|
#ifndef ASSIMP_BUILD_NO_DEBONE_PROCESS
|
||||||
# include "PostProcessing/DeboneProcess.h"
|
# include "PostProcessing/DeboneProcess.h"
|
||||||
|
|
|
@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_SPLITBYBONECOUNTPROCESS_H_INC
|
#define AI_SPLITBYBONECOUNTPROCESS_H_INC
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "BaseProcess.h"
|
#include "Common/BaseProcess.h"
|
||||||
|
|
||||||
#include <assimp/mesh.h>
|
#include <assimp/mesh.h>
|
||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
project(zip
|
project(zip
|
||||||
LANGUAGES C
|
LANGUAGES C
|
||||||
VERSION "0.1.15")
|
VERSION "0.1.18")
|
||||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
option(CMAKE_DISABLE_TESTING "Disable test creation" OFF)
|
option(CMAKE_DISABLE_TESTING "Disable test creation" OFF)
|
||||||
|
@ -16,10 +16,6 @@ elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
"${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
|
||||||
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
"${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra -Werror -pedantic")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -Wextra -Werror -pedantic")
|
||||||
if(ENABLE_COVERAGE)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
|
||||||
endif()
|
|
||||||
endif (MSVC)
|
endif (MSVC)
|
||||||
|
|
||||||
# zip
|
# zip
|
||||||
|
@ -35,7 +31,7 @@ if (NOT CMAKE_DISABLE_TESTING)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
find_package(Sanitizers)
|
find_package(Sanitizers)
|
||||||
add_sanitizers(${PROJECT_NAME} ${test_out} ${test_miniz_out})
|
add_sanitizers(${PROJECT_NAME} ${test_out})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
### A portable (OSX/Linux/Windows), simple zip library written in C
|
### A portable (OSX/Linux/Windows), simple zip library written in C
|
||||||
This is done by hacking awesome [miniz](https://code.google.com/p/miniz) library and layering functions on top of the miniz v1.15 API.
|
This is done by hacking awesome [miniz](https://code.google.com/p/miniz) library and layering functions on top of the miniz v1.15 API.
|
||||||
|
|
||||||
[![Windows](https://ci.appveyor.com/api/projects/status/bph8dr3jacgmjv32/branch/master?svg=true&label=windows)](https://ci.appveyor.com/project/kuba--/zip)
|
[![Build](https://github.com/kuba--/zip/workflows/build/badge.svg)](https://github.com/kuba--/zip/actions?query=workflow%3Abuild)
|
||||||
[![Linux](https://travis-ci.org/kuba--/zip.svg?branch=master&label=linux%2fosx)](https://travis-ci.org/kuba--/zip)
|
|
||||||
[![Version](https://badge.fury.io/gh/kuba--%2Fzip.svg)](https://github.com/kuba--/zip/releases)
|
[![Version](https://badge.fury.io/gh/kuba--%2Fzip.svg)](https://github.com/kuba--/zip/releases)
|
||||||
[![Codecov](https://codecov.io/gh/kuba--/zip/branch/master/graph/badge.svg)](https://codecov.io/gh/kuba--/zip)
|
|
||||||
|
|
||||||
|
|
||||||
# The Idea
|
# The Idea
|
||||||
|
@ -213,6 +211,53 @@ func main() {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Rust (ffi)
|
||||||
|
```rust
|
||||||
|
extern crate libc;
|
||||||
|
use std::ffi::CString;
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
pub struct Zip {
|
||||||
|
_private: [u8; 0],
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link(name = "zip")]
|
||||||
|
extern "C" {
|
||||||
|
fn zip_open(path: *const libc::c_char, level: libc::c_int, mode: libc::c_char) -> *mut Zip;
|
||||||
|
fn zip_close(zip: *mut Zip) -> libc::c_void;
|
||||||
|
|
||||||
|
fn zip_entry_open(zip: *mut Zip, entryname: *const libc::c_char) -> libc::c_int;
|
||||||
|
fn zip_entry_close(zip: *mut Zip) -> libc::c_int;
|
||||||
|
fn zip_entry_write(
|
||||||
|
zip: *mut Zip,
|
||||||
|
buf: *const libc::c_void,
|
||||||
|
bufsize: libc::size_t,
|
||||||
|
) -> libc::c_int;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let path = CString::new("/tmp/test.zip").unwrap();
|
||||||
|
let mode: libc::c_char = 'w' as libc::c_char;
|
||||||
|
|
||||||
|
let entryname = CString::new("test.txt").unwrap();
|
||||||
|
let content = "test content\0";
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let zip: *mut Zip = zip_open(path.as_ptr(), 5, mode);
|
||||||
|
{
|
||||||
|
zip_entry_open(zip, entryname.as_ptr());
|
||||||
|
{
|
||||||
|
let buf = content.as_ptr() as *const libc::c_void;
|
||||||
|
let bufsize = content.len() as libc::size_t;
|
||||||
|
zip_entry_write(zip, buf, bufsize);
|
||||||
|
}
|
||||||
|
zip_entry_close(zip);
|
||||||
|
}
|
||||||
|
zip_close(zip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Ruby (ffi)
|
### Ruby (ffi)
|
||||||
Install _ffi_ gem.
|
Install _ffi_ gem.
|
||||||
```shell
|
```shell
|
||||||
|
|
|
@ -222,6 +222,20 @@ void zip_close(struct zip_t *zip) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int zip_is64(struct zip_t *zip) {
|
||||||
|
if (!zip) {
|
||||||
|
// zip_t handler is not initialized
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!zip->archive.m_pState) {
|
||||||
|
// zip state is not initialized
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)zip->archive.m_pState->m_zip64;
|
||||||
|
}
|
||||||
|
|
||||||
int zip_entry_open(struct zip_t *zip, const char *entryname) {
|
int zip_entry_open(struct zip_t *zip, const char *entryname) {
|
||||||
size_t entrylen = 0;
|
size_t entrylen = 0;
|
||||||
mz_zip_archive *pzip = NULL;
|
mz_zip_archive *pzip = NULL;
|
||||||
|
@ -794,7 +808,8 @@ int zip_create(const char *zipname, const char *filenames[], size_t len) {
|
||||||
|
|
||||||
if (MZ_FILE_STAT(name, &file_stat) != 0) {
|
if (MZ_FILE_STAT(name, &file_stat) != 0) {
|
||||||
// problem getting information - check errno
|
// problem getting information - check errno
|
||||||
return -1;
|
status = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((file_stat.st_mode & 0200) == 0) {
|
if ((file_stat.st_mode & 0200) == 0) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
|
|
||||||
#if !defined(_SSIZE_T_DEFINED) && !defined(_SSIZE_T_DEFINED_) && \
|
#if !defined(_SSIZE_T_DEFINED) && !defined(_SSIZE_T_DEFINED_) && \
|
||||||
!defined(__DEFINED_ssize_t) && !defined(__ssize_t_defined) && \
|
!defined(__DEFINED_ssize_t) && !defined(__ssize_t_defined) && \
|
||||||
!defined(_SSIZE_T) && !defined(_SSIZE_T_)
|
!defined(_SSIZE_T) && !defined(_SSIZE_T_) && !defined(_SSIZE_T_DECLARED)
|
||||||
|
|
||||||
// 64-bit Windows is the only mainstream platform
|
// 64-bit Windows is the only mainstream platform
|
||||||
// where sizeof(long) != sizeof(void*)
|
// where sizeof(long) != sizeof(void*)
|
||||||
|
@ -37,6 +37,7 @@ typedef long ssize_t; /* byte count or error */
|
||||||
#define __ssize_t_defined
|
#define __ssize_t_defined
|
||||||
#define _SSIZE_T
|
#define _SSIZE_T
|
||||||
#define _SSIZE_T_
|
#define _SSIZE_T_
|
||||||
|
#define _SSIZE_T_DECLARED
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -90,6 +91,16 @@ extern struct zip_t *zip_open(const char *zipname, int level, char mode);
|
||||||
*/
|
*/
|
||||||
extern void zip_close(struct zip_t *zip);
|
extern void zip_close(struct zip_t *zip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if the archive has a zip64 end of central directory headers.
|
||||||
|
*
|
||||||
|
* @param zip zip archive handler.
|
||||||
|
*
|
||||||
|
* @return the return code - 1 (true), 0 (false), negative number (< 0) on
|
||||||
|
* error.
|
||||||
|
*/
|
||||||
|
extern int zip_is64(struct zip_t *zip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens an entry by name in the zip archive.
|
* Opens an entry by name in the zip archive.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,15 +2,10 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
# test
|
# test
|
||||||
set(test_out test.out)
|
set(test_out test.out)
|
||||||
set(test_miniz_out test_miniz.out)
|
|
||||||
|
|
||||||
add_executable(${test_out} test.c)
|
add_executable(${test_out} test.c)
|
||||||
target_link_libraries(${test_out} zip)
|
target_link_libraries(${test_out} zip)
|
||||||
add_executable(${test_miniz_out} test_miniz.c)
|
|
||||||
target_link_libraries(${test_miniz_out} zip)
|
|
||||||
|
|
||||||
add_test(NAME ${test_out} COMMAND ${test_out})
|
add_test(NAME ${test_out} COMMAND ${test_out})
|
||||||
add_test(NAME ${test_miniz_out} COMMAND ${test_miniz_out})
|
|
||||||
|
|
||||||
set(test_out ${test_out} PARENT_SCOPE)
|
set(test_out ${test_out} PARENT_SCOPE)
|
||||||
set(test_miniz_out ${test_miniz_out} PARENT_SCOPE)
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ static void test_write(void) {
|
||||||
assert(CRC32DATA1 == zip_entry_crc32(zip));
|
assert(CRC32DATA1 == zip_entry_crc32(zip));
|
||||||
++total_entries;
|
++total_entries;
|
||||||
assert(0 == zip_entry_close(zip));
|
assert(0 == zip_entry_close(zip));
|
||||||
|
assert(0 == zip_is64(zip));
|
||||||
zip_close(zip);
|
zip_close(zip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ static void test_read(void) {
|
||||||
size_t buftmp;
|
size_t buftmp;
|
||||||
struct zip_t *zip = zip_open(ZIPNAME, 0, 'r');
|
struct zip_t *zip = zip_open(ZIPNAME, 0, 'r');
|
||||||
assert(zip != NULL);
|
assert(zip != NULL);
|
||||||
|
assert(0 == zip_is64(zip));
|
||||||
|
|
||||||
assert(0 == zip_entry_open(zip, "test\\test-1.txt"));
|
assert(0 == zip_entry_open(zip, "test\\test-1.txt"));
|
||||||
assert(strlen(TESTDATA1) == zip_entry_size(zip));
|
assert(strlen(TESTDATA1) == zip_entry_size(zip));
|
||||||
|
@ -310,6 +311,7 @@ static void test_fwrite(void) {
|
||||||
assert(0 == zip_entry_open(zip, WFILE));
|
assert(0 == zip_entry_open(zip, WFILE));
|
||||||
assert(0 == zip_entry_fwrite(zip, WFILE));
|
assert(0 == zip_entry_fwrite(zip, WFILE));
|
||||||
assert(0 == zip_entry_close(zip));
|
assert(0 == zip_entry_close(zip));
|
||||||
|
assert(0 == zip_is64(zip));
|
||||||
|
|
||||||
zip_close(zip);
|
zip_close(zip);
|
||||||
remove(WFILE);
|
remove(WFILE);
|
||||||
|
|
|
@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
|
||||||
|
|
||||||
Copyright (c) 2006-2020, assimp team
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -45,26 +44,25 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_GENERIC_PROPERTY_H_INCLUDED
|
#define AI_GENERIC_PROPERTY_H_INCLUDED
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# pragma GCC system_header
|
# pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/ai_assert.h>
|
|
||||||
#include <assimp/Hash.h>
|
#include <assimp/Hash.h>
|
||||||
|
#include <assimp/ai_assert.h>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
inline bool SetGenericProperty(std::map<unsigned int, T> &list,
|
||||||
bool SetGenericProperty(std::map< unsigned int, T >& list,
|
const char *szName, const T &value) {
|
||||||
const char* szName, const T& value) {
|
|
||||||
ai_assert(nullptr != szName);
|
ai_assert(nullptr != szName);
|
||||||
const uint32_t hash = SuperFastHash(szName);
|
const uint32_t hash = SuperFastHash(szName);
|
||||||
|
|
||||||
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
||||||
if (it == list.end()) {
|
if (it == list.end()) {
|
||||||
list.insert(std::pair<unsigned int, T>( hash, value ));
|
list.insert(std::pair<unsigned int, T>(hash, value));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
(*it).second = value;
|
(*it).second = value;
|
||||||
|
@ -74,9 +72,8 @@ bool SetGenericProperty(std::map< unsigned int, T >& list,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
inline const T &GetGenericProperty(const std::map<unsigned int, T> &list,
|
||||||
const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
const char *szName, const T &errorReturn) {
|
||||||
const char* szName, const T& errorReturn) {
|
|
||||||
ai_assert(nullptr != szName);
|
ai_assert(nullptr != szName);
|
||||||
const uint32_t hash = SuperFastHash(szName);
|
const uint32_t hash = SuperFastHash(szName);
|
||||||
|
|
||||||
|
@ -92,22 +89,21 @@ const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
||||||
// Special version for pointer types - they will be deleted when replaced with another value
|
// Special version for pointer types - they will be deleted when replaced with another value
|
||||||
// passing NULL removes the whole property
|
// passing NULL removes the whole property
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
inline void SetGenericPropertyPtr(std::map<unsigned int, T *> &list,
|
||||||
void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
const char *szName, T *value, bool *bWasExisting = nullptr) {
|
||||||
const char* szName, T* value, bool* bWasExisting = nullptr ) {
|
|
||||||
ai_assert(nullptr != szName);
|
ai_assert(nullptr != szName);
|
||||||
const uint32_t hash = SuperFastHash(szName);
|
const uint32_t hash = SuperFastHash(szName);
|
||||||
|
|
||||||
typename std::map<unsigned int, T*>::iterator it = list.find(hash);
|
typename std::map<unsigned int, T *>::iterator it = list.find(hash);
|
||||||
if (it == list.end()) {
|
if (it == list.end()) {
|
||||||
if (bWasExisting) {
|
if (bWasExisting) {
|
||||||
*bWasExisting = false;
|
*bWasExisting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.insert(std::pair<unsigned int,T*>( hash, value ));
|
list.insert(std::pair<unsigned int, T *>(hash, value));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((*it).second != value) {
|
if ((*it).second != value) {
|
||||||
delete (*it).second;
|
delete (*it).second;
|
||||||
(*it).second = value;
|
(*it).second = value;
|
||||||
}
|
}
|
||||||
|
@ -121,9 +117,8 @@ void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
inline bool HasGenericProperty(const std::map<unsigned int, T> &list,
|
||||||
bool HasGenericProperty(const std::map< unsigned int, T >& list,
|
const char *szName) {
|
||||||
const char* szName) {
|
|
||||||
ai_assert(nullptr != szName);
|
ai_assert(nullptr != szName);
|
||||||
const uint32_t hash = SuperFastHash(szName);
|
const uint32_t hash = SuperFastHash(szName);
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ def _init(self, target = None, parent = None):
|
||||||
logger.debug(str(self) + ": Added array " + str(getattr(target, name)) + " as self." + name.lower())
|
logger.debug(str(self) + ": Added array " + str(getattr(target, name)) + " as self." + name.lower())
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if m.startswith('m'):
|
if m.startswith('m') and len(m) > 1 and m[1].upper() == m[1]:
|
||||||
|
|
||||||
if name == "parent":
|
if name == "parent":
|
||||||
setattr(target, name, parent)
|
setattr(target, name, parent)
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
cmake_minimum_required( VERSION 2.6 )
|
cmake_minimum_required( VERSION 3.0 )
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${Assimp_SOURCE_DIR}/include
|
${Assimp_SOURCE_DIR}/include
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
cmake_minimum_required( VERSION 2.6 )
|
cmake_minimum_required( VERSION 3.0 )
|
||||||
|
|
||||||
FIND_PACKAGE(DirectX REQUIRED)
|
FIND_PACKAGE(DirectX REQUIRED)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue