Merge branch 'master' into master
commit
314bdf196b
|
@ -1,2 +1,3 @@
|
||||||
patreon: assimp
|
patreon: assimp
|
||||||
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4
|
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4
|
||||||
|
open_collective: assimp
|
||||||
|
|
|
@ -7,40 +7,53 @@ on:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux:
|
job:
|
||||||
runs-on: ubuntu-latest
|
name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
name: [ubuntu-gcc, macos-clang, windows-msvc, ubuntu-clang]
|
||||||
|
# For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux.
|
||||||
|
include:
|
||||||
|
- name: windows-msvc
|
||||||
|
os: windows-latest
|
||||||
|
cxx: cl.exe
|
||||||
|
cc: cl.exe
|
||||||
|
- name: ubuntu-clang
|
||||||
|
os: ubuntu-latest
|
||||||
|
cxx: clang++
|
||||||
|
cc: clang
|
||||||
|
- name: macos-clang
|
||||||
|
os: macos-latest
|
||||||
|
cxx: clang++
|
||||||
|
cc: clang
|
||||||
|
- name: ubuntu-gcc
|
||||||
|
os: ubuntu-latest
|
||||||
|
cxx: g++
|
||||||
|
cc: gcc
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: configure
|
|
||||||
run: cmake CMakeLists.txt
|
- uses: lukka/get-cmake@latest
|
||||||
- name: build
|
|
||||||
run: cmake --build .
|
- uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
|
||||||
|
- uses: lukka/set-shell-env@v1
|
||||||
|
with:
|
||||||
|
CXX: ${{ matrix.cxx }}
|
||||||
|
CC: ${{ matrix.cc }}
|
||||||
|
|
||||||
|
- name: configure and build
|
||||||
|
uses: lukka/run-cmake@v2
|
||||||
|
with:
|
||||||
|
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||||
|
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||||
|
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release'
|
||||||
|
buildWithCMakeArgs: '-- -v'
|
||||||
|
buildDirectory: '${{ github.workspace }}/build/'
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: cd bin && ./unit
|
run: cd build/bin && ./unit
|
||||||
|
shell: bash
|
||||||
mac:
|
|
||||||
runs-on: macos-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: configure
|
|
||||||
run: cmake CMakeLists.txt
|
|
||||||
- name: build
|
|
||||||
run: cmake --build .
|
|
||||||
- name: test
|
|
||||||
run: cd bin && ./unit
|
|
||||||
|
|
||||||
windows:
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: configure
|
|
||||||
run: cmake CMakeLists.txt
|
|
||||||
- name: build
|
|
||||||
run: cmake --build . --config Release
|
|
||||||
- name: test
|
|
||||||
run: |
|
|
||||||
cd bin\Release
|
|
||||||
.\unit
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
name: C/C++ Sanitizer
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
job1:
|
||||||
|
name: adress-sanitizer
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: lukka/get-cmake@latest
|
||||||
|
- uses: lukka/set-shell-env@v1
|
||||||
|
with:
|
||||||
|
CXX: clang++
|
||||||
|
CC: clang
|
||||||
|
|
||||||
|
- name: configure and build
|
||||||
|
uses: lukka/run-cmake@v2
|
||||||
|
with:
|
||||||
|
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||||
|
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||||
|
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Debug -DASSIMP_ASAN=ON'
|
||||||
|
buildWithCMakeArgs: '-- -v'
|
||||||
|
buildDirectory: '${{ github.workspace }}/build/'
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
run: cd build/bin && ./unit
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
job2:
|
||||||
|
name: undefined-behavior-sanitizer
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: lukka/get-cmake@latest
|
||||||
|
- uses: lukka/set-shell-env@v1
|
||||||
|
with:
|
||||||
|
CXX: clang++
|
||||||
|
CC: clang
|
||||||
|
|
||||||
|
- name: configure and build
|
||||||
|
uses: lukka/run-cmake@v2
|
||||||
|
with:
|
||||||
|
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
|
||||||
|
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
|
||||||
|
cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Debug -DASSIMP_UBSAN=ON'
|
||||||
|
buildWithCMakeArgs: '-- -v'
|
||||||
|
buildDirectory: '${{ github.workspace }}/build/'
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
run: cd build/bin && ./unit
|
||||||
|
shell: bash
|
|
@ -239,22 +239,14 @@ IF( UNIX )
|
||||||
INCLUDE(GNUInstallDirs)
|
INCLUDE(GNUInstallDirs)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# enable warnings as errors ########################################
|
|
||||||
IF (MSVC)
|
|
||||||
ADD_COMPILE_OPTIONS(/WX)
|
|
||||||
ELSE()
|
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
|
||||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
|
|
||||||
ENDIF()
|
|
||||||
|
|
||||||
# Grouped compiler settings ########################################
|
# Grouped compiler settings ########################################
|
||||||
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW)
|
||||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++0x ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_STANDARD 11)
|
||||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
# hide all not-exported symbols
|
# hide all not-exported symbols
|
||||||
SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}")
|
||||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||||
SET(LIBSTDC++_LIBRARIES -lstdc++)
|
SET(LIBSTDC++_LIBRARIES -lstdc++)
|
||||||
ELSEIF(MSVC)
|
ELSEIF(MSVC)
|
||||||
|
@ -267,10 +259,10 @@ ELSEIF(MSVC)
|
||||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
|
||||||
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
|
||||||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||||
SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_STANDARD 11)
|
||||||
SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
|
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
|
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
|
||||||
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
|
||||||
ELSEIF( CMAKE_COMPILER_IS_MINGW )
|
ELSEIF( CMAKE_COMPILER_IS_MINGW )
|
||||||
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
|
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
|
||||||
|
|
23
Readme.md
23
Readme.md
|
@ -2,6 +2,7 @@ Open Asset Import Library (assimp)
|
||||||
==================================
|
==================================
|
||||||
A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data.
|
A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data.
|
||||||
### Current project status ###
|
### Current project status ###
|
||||||
|
[![Financial Contributors on Open Collective](https://opencollective.com/assimp/all/badge.svg?label=financial+contributors)](https://opencollective.com/assimp)
|
||||||
![C/C++ CI](https://github.com/assimp/assimp/workflows/C/C++%20CI/badge.svg)
|
![C/C++ CI](https://github.com/assimp/assimp/workflows/C/C++%20CI/badge.svg)
|
||||||
[![Linux Build Status](https://travis-ci.org/assimp/assimp.svg)](https://travis-ci.org/assimp/assimp)
|
[![Linux Build Status](https://travis-ci.org/assimp/assimp.svg)](https://travis-ci.org/assimp/assimp)
|
||||||
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
|
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp)
|
||||||
|
@ -179,6 +180,28 @@ And we also have a Gitter-channel:Gitter [![Join the chat at https://gitter.im/a
|
||||||
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
|
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
|
||||||
a pull request with your changes against the main repository's `master` branch.
|
a pull request with your changes against the main repository's `master` branch.
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
### Code Contributors
|
||||||
|
|
||||||
|
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||||
|
|
||||||
|
<a href="https://github.com/assimp/assimp/graphs/contributors"><img src="https://opencollective.com/assimp/contributors.svg?width=890&button=false" /></a>
|
||||||
|
|
||||||
|
### Financial Contributors
|
||||||
|
|
||||||
|
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/assimp/contribute)]
|
||||||
|
|
||||||
|
#### Individuals
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/assimp"><img src="https://opencollective.com/assimp/individuals.svg?width=890"></a>
|
||||||
|
|
||||||
|
#### Organizations
|
||||||
|
|
||||||
|
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/assimp/contribute)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/assimp/organization/0/website"><img src="https://opencollective.com/assimp/organization/0/avatar.svg"></a>
|
||||||
|
|
||||||
### License ###
|
### License ###
|
||||||
Our license is based on the modified, __3-clause BSD__-License.
|
Our license is based on the modified, __3-clause BSD__-License.
|
||||||
|
|
||||||
|
|
|
@ -142,11 +142,11 @@ void Parser::LogWarning(const char* szWarn)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != szWarn);
|
ai_assert(NULL != szWarn);
|
||||||
|
|
||||||
char szTemp[1024];
|
char szTemp[2048];
|
||||||
#if _MSC_VER >= 1400
|
#if _MSC_VER >= 1400
|
||||||
sprintf_s(szTemp, "Line %u: %s",iLineNumber,szWarn);
|
sprintf_s(szTemp, "Line %u: %s",iLineNumber,szWarn);
|
||||||
#else
|
#else
|
||||||
ai_snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn);
|
ai_snprintf(szTemp,sizeof(szTemp),"Line %u: %s",iLineNumber,szWarn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// output the warning to the logger ...
|
// output the warning to the logger ...
|
||||||
|
|
|
@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @brief Conversion of Blender's new BMesh stuff
|
* @brief Conversion of Blender's new BMesh stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
|
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
|
||||||
|
|
||||||
#include "BlenderDNA.h"
|
#include "BlenderDNA.h"
|
||||||
|
@ -181,6 +180,7 @@ void BlenderBMeshConverter::AddFace( int v1, int v2, int v3, int v4 )
|
||||||
face.v2 = v2;
|
face.v2 = v2;
|
||||||
face.v3 = v3;
|
face.v3 = v3;
|
||||||
face.v4 = v4;
|
face.v4 = v4;
|
||||||
|
face.flag = 0;
|
||||||
// TODO - Work out how materials work
|
// TODO - Work out how materials work
|
||||||
face.mat_nr = 0;
|
face.mat_nr = 0;
|
||||||
triMesh->mface.push_back( face );
|
triMesh->mface.push_back( face );
|
||||||
|
|
|
@ -73,11 +73,11 @@ ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index)
|
||||||
|
|
||||||
aiExportFormatDesc *desc = new aiExportFormatDesc;
|
aiExportFormatDesc *desc = new aiExportFormatDesc;
|
||||||
desc->description = new char[ strlen( orig->description ) + 1 ]();
|
desc->description = new char[ strlen( orig->description ) + 1 ]();
|
||||||
::strncpy( (char*) desc->description, orig->description, strlen( orig->description ) );
|
::memcpy( (char*) desc->description, orig->description, strlen( orig->description ) );
|
||||||
desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ]();
|
desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ]();
|
||||||
::strncpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) );
|
::memcpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) );
|
||||||
desc->id = new char[ strlen( orig->id ) + 1 ]();
|
desc->id = new char[ strlen( orig->id ) + 1 ]();
|
||||||
::strncpy( ( char* ) desc->id, orig->id, strlen( orig->id ) );
|
::memcpy( ( char* ) desc->id, orig->id, strlen( orig->id ) );
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1134,6 +1134,13 @@ ENDIF ()
|
||||||
ADD_LIBRARY( assimp ${assimp_src} )
|
ADD_LIBRARY( assimp ${assimp_src} )
|
||||||
ADD_LIBRARY(assimp::assimp ALIAS assimp)
|
ADD_LIBRARY(assimp::assimp ALIAS assimp)
|
||||||
|
|
||||||
|
# enable warnings as errors ########################################
|
||||||
|
IF (MSVC)
|
||||||
|
TARGET_COMPILE_OPTIONS(assimp PRIVATE /WX)
|
||||||
|
ELSE()
|
||||||
|
TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
|
TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
|
||||||
|
|
|
@ -994,8 +994,7 @@ void SceneCombiner::CopySceneFlat(aiScene** _dest,const aiScene* src) {
|
||||||
} else {
|
} else {
|
||||||
*_dest = new aiScene();
|
*_dest = new aiScene();
|
||||||
}
|
}
|
||||||
|
CopyScene(_dest, src, false);
|
||||||
::memcpy(*_dest,src,sizeof(aiScene));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -1066,7 +1065,7 @@ void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) {
|
||||||
aiMesh* dest = *_dest = new aiMesh();
|
aiMesh* dest = *_dest = new aiMesh();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest,src,sizeof(aiMesh));
|
*dest = *src;
|
||||||
|
|
||||||
// and reallocate all arrays
|
// and reallocate all arrays
|
||||||
GetArrayCopy( dest->mVertices, dest->mNumVertices );
|
GetArrayCopy( dest->mVertices, dest->mNumVertices );
|
||||||
|
@ -1105,7 +1104,7 @@ void SceneCombiner::Copy(aiAnimMesh** _dest, const aiAnimMesh* src) {
|
||||||
aiAnimMesh* dest = *_dest = new aiAnimMesh();
|
aiAnimMesh* dest = *_dest = new aiAnimMesh();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest, src, sizeof(aiAnimMesh));
|
*dest = *src;
|
||||||
|
|
||||||
// and reallocate all arrays
|
// and reallocate all arrays
|
||||||
GetArrayCopy(dest->mVertices, dest->mNumVertices);
|
GetArrayCopy(dest->mVertices, dest->mNumVertices);
|
||||||
|
@ -1162,7 +1161,7 @@ void SceneCombiner::Copy(aiTexture** _dest, const aiTexture* src) {
|
||||||
aiTexture* dest = *_dest = new aiTexture();
|
aiTexture* dest = *_dest = new aiTexture();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest,src,sizeof(aiTexture));
|
*dest = *src;
|
||||||
|
|
||||||
// and reallocate all arrays. We must do it manually here
|
// and reallocate all arrays. We must do it manually here
|
||||||
const char* old = (const char*)dest->pcData;
|
const char* old = (const char*)dest->pcData;
|
||||||
|
@ -1192,7 +1191,7 @@ void SceneCombiner::Copy( aiAnimation** _dest, const aiAnimation* src ) {
|
||||||
aiAnimation* dest = *_dest = new aiAnimation();
|
aiAnimation* dest = *_dest = new aiAnimation();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest,src,sizeof(aiAnimation));
|
*dest = *src;
|
||||||
|
|
||||||
// and reallocate all arrays
|
// and reallocate all arrays
|
||||||
CopyPtrArray( dest->mChannels, src->mChannels, dest->mNumChannels );
|
CopyPtrArray( dest->mChannels, src->mChannels, dest->mNumChannels );
|
||||||
|
@ -1208,7 +1207,7 @@ void SceneCombiner::Copy(aiNodeAnim** _dest, const aiNodeAnim* src) {
|
||||||
aiNodeAnim* dest = *_dest = new aiNodeAnim();
|
aiNodeAnim* dest = *_dest = new aiNodeAnim();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest,src,sizeof(aiNodeAnim));
|
*dest = *src;
|
||||||
|
|
||||||
// and reallocate all arrays
|
// and reallocate all arrays
|
||||||
GetArrayCopy( dest->mPositionKeys, dest->mNumPositionKeys );
|
GetArrayCopy( dest->mPositionKeys, dest->mNumPositionKeys );
|
||||||
|
@ -1224,7 +1223,7 @@ void SceneCombiner::Copy(aiMeshMorphAnim** _dest, const aiMeshMorphAnim* src) {
|
||||||
aiMeshMorphAnim* dest = *_dest = new aiMeshMorphAnim();
|
aiMeshMorphAnim* dest = *_dest = new aiMeshMorphAnim();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest,src,sizeof(aiMeshMorphAnim));
|
*dest = *src;
|
||||||
|
|
||||||
// and reallocate all arrays
|
// and reallocate all arrays
|
||||||
GetArrayCopy( dest->mKeys, dest->mNumKeys );
|
GetArrayCopy( dest->mKeys, dest->mNumKeys );
|
||||||
|
@ -1245,7 +1244,7 @@ void SceneCombiner::Copy( aiCamera** _dest,const aiCamera* src) {
|
||||||
aiCamera* dest = *_dest = new aiCamera();
|
aiCamera* dest = *_dest = new aiCamera();
|
||||||
|
|
||||||
// get a flat copy, that's already OK
|
// get a flat copy, that's already OK
|
||||||
::memcpy(dest,src,sizeof(aiCamera));
|
*dest = *src;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -1257,7 +1256,7 @@ void SceneCombiner::Copy(aiLight** _dest, const aiLight* src) {
|
||||||
aiLight* dest = *_dest = new aiLight();
|
aiLight* dest = *_dest = new aiLight();
|
||||||
|
|
||||||
// get a flat copy, that's already OK
|
// get a flat copy, that's already OK
|
||||||
::memcpy(dest,src,sizeof(aiLight));
|
*dest = *src;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -1269,10 +1268,7 @@ void SceneCombiner::Copy(aiBone** _dest, const aiBone* src) {
|
||||||
aiBone* dest = *_dest = new aiBone();
|
aiBone* dest = *_dest = new aiBone();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest,src,sizeof(aiBone));
|
*dest = *src;
|
||||||
|
|
||||||
// and reallocate all arrays
|
|
||||||
GetArrayCopy( dest->mWeights, dest->mNumWeights );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -1283,7 +1279,7 @@ void SceneCombiner::Copy (aiNode** _dest, const aiNode* src)
|
||||||
aiNode* dest = *_dest = new aiNode();
|
aiNode* dest = *_dest = new aiNode();
|
||||||
|
|
||||||
// get a flat copy
|
// get a flat copy
|
||||||
::memcpy(dest,src,sizeof(aiNode));
|
*dest = *src;
|
||||||
|
|
||||||
if (src->mMetaData) {
|
if (src->mMetaData) {
|
||||||
Copy(&dest->mMetaData, src->mMetaData);
|
Copy(&dest->mMetaData, src->mMetaData);
|
||||||
|
|
|
@ -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,
|
||||||
|
@ -50,71 +48,60 @@ using namespace Assimp;
|
||||||
|
|
||||||
// CHAR_BIT seems to be defined under MVSC, but not under GCC. Pray that the correct value is 8.
|
// CHAR_BIT seems to be defined under MVSC, but not under GCC. Pray that the correct value is 8.
|
||||||
#ifndef CHAR_BIT
|
#ifndef CHAR_BIT
|
||||||
# define CHAR_BIT 8
|
#define CHAR_BIT 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
const aiVector3D PlaneInit(0.8523f, 0.34321f, 0.5736f);
|
||||||
# pragma warning(disable : 4127)
|
|
||||||
#endif // _WIN32
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructs a spatially sorted representation from the given position array.
|
// Constructs a spatially sorted representation from the given position array.
|
||||||
SpatialSort::SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions,
|
// define the reference plane. We choose some arbitrary vector away from all basic axises
|
||||||
unsigned int pElementOffset)
|
// in the hope that no model spreads all its vertices along this plane.
|
||||||
|
SpatialSort::SpatialSort(const aiVector3D *pPositions, unsigned int pNumPositions, unsigned int pElementOffset) :
|
||||||
// define the reference plane. We choose some arbitrary vector away from all basic axises
|
mPlaneNormal(PlaneInit) {
|
||||||
// in the hope that no model spreads all its vertices along this plane.
|
|
||||||
: mPlaneNormal(0.8523f, 0.34321f, 0.5736f)
|
|
||||||
{
|
|
||||||
mPlaneNormal.Normalize();
|
mPlaneNormal.Normalize();
|
||||||
Fill(pPositions,pNumPositions,pElementOffset);
|
Fill(pPositions, pNumPositions, pElementOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SpatialSort :: SpatialSort()
|
SpatialSort::SpatialSort() :
|
||||||
: mPlaneNormal(0.8523f, 0.34321f, 0.5736f)
|
mPlaneNormal(PlaneInit) {
|
||||||
{
|
|
||||||
mPlaneNormal.Normalize();
|
mPlaneNormal.Normalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor
|
// Destructor
|
||||||
SpatialSort::~SpatialSort()
|
SpatialSort::~SpatialSort() {
|
||||||
{
|
// empty
|
||||||
// nothing to do here, everything destructs automatically
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SpatialSort::Fill( const aiVector3D* pPositions, unsigned int pNumPositions,
|
void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||||
unsigned int pElementOffset,
|
unsigned int pElementOffset,
|
||||||
bool pFinalize /*= true */)
|
bool pFinalize /*= true */) {
|
||||||
{
|
|
||||||
mPositions.clear();
|
mPositions.clear();
|
||||||
Append(pPositions,pNumPositions,pElementOffset,pFinalize);
|
Append(pPositions, pNumPositions, pElementOffset, pFinalize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SpatialSort :: Finalize()
|
void SpatialSort::Finalize() {
|
||||||
{
|
std::sort(mPositions.begin(), mPositions.end());
|
||||||
std::sort( mPositions.begin(), mPositions.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SpatialSort::Append( const aiVector3D* pPositions, unsigned int pNumPositions,
|
void SpatialSort::Append(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||||
unsigned int pElementOffset,
|
unsigned int pElementOffset,
|
||||||
bool pFinalize /*= true */)
|
bool pFinalize /*= true */) {
|
||||||
{
|
|
||||||
// store references to all given positions along with their distance to the reference plane
|
// store references to all given positions along with their distance to the reference plane
|
||||||
const size_t initial = mPositions.size();
|
const size_t initial = mPositions.size();
|
||||||
mPositions.reserve(initial + (pFinalize?pNumPositions:pNumPositions*2));
|
mPositions.reserve(initial + (pFinalize ? pNumPositions : pNumPositions * 2));
|
||||||
for( unsigned int a = 0; a < pNumPositions; a++)
|
for (unsigned int a = 0; a < pNumPositions; a++) {
|
||||||
{
|
const char *tempPointer = reinterpret_cast<const char *>(pPositions);
|
||||||
const char* tempPointer = reinterpret_cast<const char*> (pPositions);
|
const aiVector3D *vec = reinterpret_cast<const aiVector3D *>(tempPointer + a * pElementOffset);
|
||||||
const aiVector3D* vec = reinterpret_cast<const aiVector3D*> (tempPointer + a * pElementOffset);
|
|
||||||
|
|
||||||
// store position by index and distance
|
// store position by index and distance
|
||||||
ai_real distance = *vec * mPlaneNormal;
|
ai_real distance = *vec * mPlaneNormal;
|
||||||
mPositions.push_back( Entry( static_cast<unsigned int>(a+initial), *vec, distance));
|
mPositions.push_back(Entry(static_cast<unsigned int>(a + initial), *vec, distance));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFinalize) {
|
if (pFinalize) {
|
||||||
|
@ -125,9 +112,8 @@ void SpatialSort::Append( const aiVector3D* pPositions, unsigned int pNumPositio
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns an iterator for all positions close to the given position.
|
// Returns an iterator for all positions close to the given position.
|
||||||
void SpatialSort::FindPositions( const aiVector3D& pPosition,
|
void SpatialSort::FindPositions(const aiVector3D &pPosition,
|
||||||
ai_real pRadius, std::vector<unsigned int>& poResults) const
|
ai_real pRadius, std::vector<unsigned int> &poResults) const {
|
||||||
{
|
|
||||||
const ai_real dist = pPosition * mPlaneNormal;
|
const ai_real dist = pPosition * mPlaneNormal;
|
||||||
const ai_real minDist = dist - pRadius, maxDist = dist + pRadius;
|
const ai_real minDist = dist - pRadius, maxDist = dist + pRadius;
|
||||||
|
|
||||||
|
@ -135,19 +121,18 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition,
|
||||||
poResults.clear();
|
poResults.clear();
|
||||||
|
|
||||||
// quick check for positions outside the range
|
// quick check for positions outside the range
|
||||||
if( mPositions.size() == 0)
|
if (mPositions.size() == 0)
|
||||||
return;
|
return;
|
||||||
if( maxDist < mPositions.front().mDistance)
|
if (maxDist < mPositions.front().mDistance)
|
||||||
return;
|
return;
|
||||||
if( minDist > mPositions.back().mDistance)
|
if (minDist > mPositions.back().mDistance)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// do a binary search for the minimal distance to start the iteration there
|
// do a binary search for the minimal distance to start the iteration there
|
||||||
unsigned int index = (unsigned int)mPositions.size() / 2;
|
unsigned int index = (unsigned int)mPositions.size() / 2;
|
||||||
unsigned int binaryStepSize = (unsigned int)mPositions.size() / 4;
|
unsigned int binaryStepSize = (unsigned int)mPositions.size() / 4;
|
||||||
while( binaryStepSize > 1)
|
while (binaryStepSize > 1) {
|
||||||
{
|
if (mPositions[index].mDistance < minDist)
|
||||||
if( mPositions[index].mDistance < minDist)
|
|
||||||
index += binaryStepSize;
|
index += binaryStepSize;
|
||||||
else
|
else
|
||||||
index -= binaryStepSize;
|
index -= binaryStepSize;
|
||||||
|
@ -157,21 +142,20 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition,
|
||||||
|
|
||||||
// depending on the direction of the last step we need to single step a bit back or forth
|
// depending on the direction of the last step we need to single step a bit back or forth
|
||||||
// to find the actual beginning element of the range
|
// to find the actual beginning element of the range
|
||||||
while( index > 0 && mPositions[index].mDistance > minDist)
|
while (index > 0 && mPositions[index].mDistance > minDist)
|
||||||
index--;
|
index--;
|
||||||
while( index < (mPositions.size() - 1) && mPositions[index].mDistance < minDist)
|
while (index < (mPositions.size() - 1) && mPositions[index].mDistance < minDist)
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
// Mow start iterating from there until the first position lays outside of the distance range.
|
// Mow start iterating from there until the first position lays outside of the distance range.
|
||||||
// Add all positions inside the distance range within the given radius to the result aray
|
// Add all positions inside the distance range within the given radius to the result aray
|
||||||
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
|
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
|
||||||
const ai_real pSquared = pRadius*pRadius;
|
const ai_real pSquared = pRadius * pRadius;
|
||||||
while( it->mDistance < maxDist)
|
while (it->mDistance < maxDist) {
|
||||||
{
|
if ((it->mPosition - pPosition).SquareLength() < pSquared)
|
||||||
if( (it->mPosition - pPosition).SquareLength() < pSquared)
|
poResults.push_back(it->mIndex);
|
||||||
poResults.push_back( it->mIndex);
|
|
||||||
++it;
|
++it;
|
||||||
if( it == mPositions.end())
|
if (it == mPositions.end())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,70 +164,74 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition,
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Binary, signed-integer representation of a single-precision floating-point value.
|
// Binary, signed-integer representation of a single-precision floating-point value.
|
||||||
// IEEE 754 says: "If two floating-point numbers in the same format are ordered then they are
|
// IEEE 754 says: "If two floating-point numbers in the same format are ordered then they are
|
||||||
// ordered the same way when their bits are reinterpreted as sign-magnitude integers."
|
// ordered the same way when their bits are reinterpreted as sign-magnitude integers."
|
||||||
// This allows us to convert all floating-point numbers to signed integers of arbitrary size
|
// This allows us to convert all floating-point numbers to signed integers of arbitrary size
|
||||||
// and then use them to work with ULPs (Units in the Last Place, for high-precision
|
// and then use them to work with ULPs (Units in the Last Place, for high-precision
|
||||||
// computations) or to compare them (integer comparisons are faster than floating-point
|
// computations) or to compare them (integer comparisons are faster than floating-point
|
||||||
// comparisons on many platforms).
|
// comparisons on many platforms).
|
||||||
typedef ai_int BinFloat;
|
typedef ai_int BinFloat;
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
// Converts the bit pattern of a floating-point number to its signed integer representation.
|
// Converts the bit pattern of a floating-point number to its signed integer representation.
|
||||||
BinFloat ToBinary( const ai_real & pValue) {
|
BinFloat ToBinary(const ai_real &pValue) {
|
||||||
|
|
||||||
// If this assertion fails, signed int is not big enough to store a float on your platform.
|
// If this assertion fails, signed int is not big enough to store a float on your platform.
|
||||||
// Please correct the declaration of BinFloat a few lines above - but do it in a portable,
|
// Please correct the declaration of BinFloat a few lines above - but do it in a portable,
|
||||||
// #ifdef'd manner!
|
// #ifdef'd manner!
|
||||||
static_assert( sizeof(BinFloat) >= sizeof(ai_real), "sizeof(BinFloat) >= sizeof(ai_real)");
|
static_assert(sizeof(BinFloat) >= sizeof(ai_real), "sizeof(BinFloat) >= sizeof(ai_real)");
|
||||||
|
|
||||||
#if defined( _MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
// If this assertion fails, Visual C++ has finally moved to ILP64. This means that this
|
// If this assertion fails, Visual C++ has finally moved to ILP64. This means that this
|
||||||
// code has just become legacy code! Find out the current value of _MSC_VER and modify
|
// code has just become legacy code! Find out the current value of _MSC_VER and modify
|
||||||
// the #if above so it evaluates false on the current and all upcoming VC versions (or
|
// the #if above so it evaluates false on the current and all upcoming VC versions (or
|
||||||
// on the current platform, if LP64 or LLP64 are still used on other platforms).
|
// on the current platform, if LP64 or LLP64 are still used on other platforms).
|
||||||
static_assert( sizeof(BinFloat) == sizeof(ai_real), "sizeof(BinFloat) == sizeof(ai_real)");
|
static_assert(sizeof(BinFloat) == sizeof(ai_real), "sizeof(BinFloat) == sizeof(ai_real)");
|
||||||
|
|
||||||
// This works best on Visual C++, but other compilers have their problems with it.
|
// This works best on Visual C++, but other compilers have their problems with it.
|
||||||
const BinFloat binValue = reinterpret_cast<BinFloat const &>(pValue);
|
const BinFloat binValue = reinterpret_cast<BinFloat const &>(pValue);
|
||||||
#else
|
//::memcpy(&binValue, &pValue, sizeof(pValue));
|
||||||
// On many compilers, reinterpreting a float address as an integer causes aliasing
|
//return binValue;
|
||||||
// problems. This is an ugly but more or less safe way of doing it.
|
#else
|
||||||
union {
|
// On many compilers, reinterpreting a float address as an integer causes aliasing
|
||||||
ai_real asFloat;
|
// problems. This is an ugly but more or less safe way of doing it.
|
||||||
BinFloat asBin;
|
union {
|
||||||
} conversion;
|
ai_real asFloat;
|
||||||
conversion.asBin = 0; // zero empty space in case sizeof(BinFloat) > sizeof(float)
|
BinFloat asBin;
|
||||||
conversion.asFloat = pValue;
|
} conversion;
|
||||||
const BinFloat binValue = conversion.asBin;
|
conversion.asBin = 0; // zero empty space in case sizeof(BinFloat) > sizeof(float)
|
||||||
#endif
|
conversion.asFloat = pValue;
|
||||||
|
const BinFloat binValue = conversion.asBin;
|
||||||
|
#endif
|
||||||
|
|
||||||
// floating-point numbers are of sign-magnitude format, so find out what signed number
|
// floating-point numbers are of sign-magnitude format, so find out what signed number
|
||||||
// representation we must convert negative values to.
|
// representation we must convert negative values to.
|
||||||
// See http://en.wikipedia.org/wiki/Signed_number_representations.
|
// See http://en.wikipedia.org/wiki/Signed_number_representations.
|
||||||
|
|
||||||
// Two's complement?
|
// Two's complement?
|
||||||
if( (-42 == (~42 + 1)) && (binValue & 0x80000000))
|
bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000));
|
||||||
return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue;
|
bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000));
|
||||||
// One's complement?
|
bool SignedMagnitude = ((-42 == (42 | (-0))) && (binValue & 0x80000000));
|
||||||
else if ( (-42 == ~42) && (binValue & 0x80000000))
|
|
||||||
return BinFloat(-0) - binValue;
|
if (DefaultValue)
|
||||||
// Sign-magnitude?
|
return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue;
|
||||||
else if( (-42 == (42 | (-0))) && (binValue & 0x80000000)) // -0 = 1000... binary
|
// One's complement?
|
||||||
return binValue;
|
else if (OneComplement)
|
||||||
else
|
return BinFloat(-0) - binValue;
|
||||||
return binValue;
|
// Sign-magnitude?
|
||||||
}
|
else if (SignedMagnitude) // -0 = 1000... binary
|
||||||
|
return binValue;
|
||||||
|
else
|
||||||
|
return binValue;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Fills an array with indices of all positions identical to the given position. In opposite to
|
// Fills an array with indices of all positions identical to the given position. In opposite to
|
||||||
// FindPositions(), not an epsilon is used but a (very low) tolerance of four floating-point units.
|
// FindPositions(), not an epsilon is used but a (very low) tolerance of four floating-point units.
|
||||||
void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition,
|
void SpatialSort::FindIdenticalPositions(const aiVector3D &pPosition, std::vector<unsigned int> &poResults) const {
|
||||||
std::vector<unsigned int>& poResults) const
|
|
||||||
{
|
|
||||||
// Epsilons have a huge disadvantage: they are of constant precision, while floating-point
|
// Epsilons have a huge disadvantage: they are of constant precision, while floating-point
|
||||||
// values are of log2 precision. If you apply e=0.01 to 100, the epsilon is rather small, but
|
// values are of log2 precision. If you apply e=0.01 to 100, the epsilon is rather small, but
|
||||||
// if you apply it to 0.001, it is enormous.
|
// if you apply it to 0.001, it is enormous.
|
||||||
|
@ -269,20 +257,19 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition,
|
||||||
|
|
||||||
// Convert the plane distance to its signed integer representation so the ULPs tolerance can be
|
// Convert the plane distance to its signed integer representation so the ULPs tolerance can be
|
||||||
// applied. For some reason, VC won't optimize two calls of the bit pattern conversion.
|
// applied. For some reason, VC won't optimize two calls of the bit pattern conversion.
|
||||||
const BinFloat minDistBinary = ToBinary( pPosition * mPlaneNormal) - distanceToleranceInULPs;
|
const BinFloat minDistBinary = ToBinary(pPosition * mPlaneNormal) - distanceToleranceInULPs;
|
||||||
const BinFloat maxDistBinary = minDistBinary + 2 * distanceToleranceInULPs;
|
const BinFloat maxDistBinary = minDistBinary + 2 * distanceToleranceInULPs;
|
||||||
|
|
||||||
// clear the array in this strange fashion because a simple clear() would also deallocate
|
// clear the array in this strange fashion because a simple clear() would also deallocate
|
||||||
// the array which we want to avoid
|
// the array which we want to avoid
|
||||||
poResults.resize( 0 );
|
poResults.resize(0);
|
||||||
|
|
||||||
// do a binary search for the minimal distance to start the iteration there
|
// do a binary search for the minimal distance to start the iteration there
|
||||||
unsigned int index = (unsigned int)mPositions.size() / 2;
|
unsigned int index = (unsigned int)mPositions.size() / 2;
|
||||||
unsigned int binaryStepSize = (unsigned int)mPositions.size() / 4;
|
unsigned int binaryStepSize = (unsigned int)mPositions.size() / 4;
|
||||||
while( binaryStepSize > 1)
|
while (binaryStepSize > 1) {
|
||||||
{
|
|
||||||
// Ugly, but conditional jumps are faster with integers than with floats
|
// Ugly, but conditional jumps are faster with integers than with floats
|
||||||
if( minDistBinary > ToBinary(mPositions[index].mDistance))
|
if (minDistBinary > ToBinary(mPositions[index].mDistance))
|
||||||
index += binaryStepSize;
|
index += binaryStepSize;
|
||||||
else
|
else
|
||||||
index -= binaryStepSize;
|
index -= binaryStepSize;
|
||||||
|
@ -292,20 +279,19 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition,
|
||||||
|
|
||||||
// depending on the direction of the last step we need to single step a bit back or forth
|
// depending on the direction of the last step we need to single step a bit back or forth
|
||||||
// to find the actual beginning element of the range
|
// to find the actual beginning element of the range
|
||||||
while( index > 0 && minDistBinary < ToBinary(mPositions[index].mDistance) )
|
while (index > 0 && minDistBinary < ToBinary(mPositions[index].mDistance))
|
||||||
index--;
|
index--;
|
||||||
while( index < (mPositions.size() - 1) && minDistBinary > ToBinary(mPositions[index].mDistance))
|
while (index < (mPositions.size() - 1) && minDistBinary > ToBinary(mPositions[index].mDistance))
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
// Now start iterating from there until the first position lays outside of the distance range.
|
// Now start iterating from there until the first position lays outside of the distance range.
|
||||||
// Add all positions inside the distance range within the tolerance to the result array
|
// Add all positions inside the distance range within the tolerance to the result array
|
||||||
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
|
std::vector<Entry>::const_iterator it = mPositions.begin() + index;
|
||||||
while( ToBinary(it->mDistance) < maxDistBinary)
|
while (ToBinary(it->mDistance) < maxDistBinary) {
|
||||||
{
|
if (distance3DToleranceInULPs >= ToBinary((it->mPosition - pPosition).SquareLength()))
|
||||||
if( distance3DToleranceInULPs >= ToBinary((it->mPosition - pPosition).SquareLength()))
|
|
||||||
poResults.push_back(it->mIndex);
|
poResults.push_back(it->mIndex);
|
||||||
++it;
|
++it;
|
||||||
if( it == mPositions.end())
|
if (it == mPositions.end())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,22 +299,19 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
unsigned int SpatialSort::GenerateMappingTable(std::vector<unsigned int>& fill, ai_real pRadius) const
|
unsigned int SpatialSort::GenerateMappingTable(std::vector<unsigned int> &fill, ai_real pRadius) const {
|
||||||
{
|
fill.resize(mPositions.size(), UINT_MAX);
|
||||||
fill.resize(mPositions.size(),UINT_MAX);
|
|
||||||
ai_real dist, maxDist;
|
ai_real dist, maxDist;
|
||||||
|
|
||||||
unsigned int t=0;
|
unsigned int t = 0;
|
||||||
const ai_real pSquared = pRadius*pRadius;
|
const ai_real pSquared = pRadius * pRadius;
|
||||||
for (size_t i = 0; i < mPositions.size();) {
|
for (size_t i = 0; i < mPositions.size();) {
|
||||||
dist = mPositions[i].mPosition * mPlaneNormal;
|
dist = mPositions[i].mPosition * mPlaneNormal;
|
||||||
maxDist = dist + pRadius;
|
maxDist = dist + pRadius;
|
||||||
|
|
||||||
fill[mPositions[i].mIndex] = t;
|
fill[mPositions[i].mIndex] = t;
|
||||||
const aiVector3D& oldpos = mPositions[i].mPosition;
|
const aiVector3D &oldpos = mPositions[i].mPosition;
|
||||||
for (++i; i < fill.size() && mPositions[i].mDistance < maxDist
|
for (++i; i < fill.size() && mPositions[i].mDistance < maxDist && (mPositions[i].mPosition - oldpos).SquareLength() < pSquared; ++i) {
|
||||||
&& (mPositions[i].mPosition - oldpos).SquareLength() < pSquared; ++i)
|
|
||||||
{
|
|
||||||
fill[mPositions[i].mIndex] = t;
|
fill[mPositions[i].mIndex] = t;
|
||||||
}
|
}
|
||||||
++t;
|
++t;
|
||||||
|
@ -338,7 +321,7 @@ unsigned int SpatialSort::GenerateMappingTable(std::vector<unsigned int>& fill,
|
||||||
|
|
||||||
// debug invariant: mPositions[i].mIndex values must range from 0 to mPositions.size()-1
|
// debug invariant: mPositions[i].mIndex values must range from 0 to mPositions.size()-1
|
||||||
for (size_t i = 0; i < fill.size(); ++i) {
|
for (size_t i = 0; i < fill.size(); ++i) {
|
||||||
ai_assert(fill[i]<mPositions.size());
|
ai_assert(fill[i] < mPositions.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3401,7 +3401,8 @@ void FBXConverter::ConvertGlobalSettings() {
|
||||||
mSceneOut->mMetaData->Set(5, "CoordAxisSign", doc.GlobalSettings().CoordAxisSign());
|
mSceneOut->mMetaData->Set(5, "CoordAxisSign", doc.GlobalSettings().CoordAxisSign());
|
||||||
mSceneOut->mMetaData->Set(6, "OriginalUpAxis", doc.GlobalSettings().OriginalUpAxis());
|
mSceneOut->mMetaData->Set(6, "OriginalUpAxis", doc.GlobalSettings().OriginalUpAxis());
|
||||||
mSceneOut->mMetaData->Set(7, "OriginalUpAxisSign", doc.GlobalSettings().OriginalUpAxisSign());
|
mSceneOut->mMetaData->Set(7, "OriginalUpAxisSign", doc.GlobalSettings().OriginalUpAxisSign());
|
||||||
mSceneOut->mMetaData->Set(8, "UnitScaleFactor", (double)doc.GlobalSettings().UnitScaleFactor());
|
//const double unitScaleFactor = (double)doc.GlobalSettings().UnitScaleFactor();
|
||||||
|
mSceneOut->mMetaData->Set(8, "UnitScaleFactor", doc.GlobalSettings().UnitScaleFactor());
|
||||||
mSceneOut->mMetaData->Set(9, "OriginalUnitScaleFactor", doc.GlobalSettings().OriginalUnitScaleFactor());
|
mSceneOut->mMetaData->Set(9, "OriginalUnitScaleFactor", doc.GlobalSettings().OriginalUnitScaleFactor());
|
||||||
mSceneOut->mMetaData->Set(10, "AmbientColor", doc.GlobalSettings().AmbientColor());
|
mSceneOut->mMetaData->Set(10, "AmbientColor", doc.GlobalSettings().AmbientColor());
|
||||||
mSceneOut->mMetaData->Set(11, "FrameRate", (int)doc.GlobalSettings().TimeMode());
|
mSceneOut->mMetaData->Set(11, "FrameRate", (int)doc.GlobalSettings().TimeMode());
|
||||||
|
|
|
@ -1556,7 +1556,7 @@ static int _m3dstbi__create_png_image(_m3dstbi__png *a, unsigned char *image_dat
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _m3dstbi__compute_transparency(_m3dstbi__png *z, unsigned char tc[3], int out_n) {
|
static int _m3dstbi__compute_transparency(_m3dstbi__png *z, unsigned char* tc, int out_n) {
|
||||||
_m3dstbi__context *s = z->s;
|
_m3dstbi__context *s = z->s;
|
||||||
_m3dstbi__uint32 i, pixel_count = s->img_x * s->img_y;
|
_m3dstbi__uint32 i, pixel_count = s->img_x * s->img_y;
|
||||||
unsigned char *p = z->out;
|
unsigned char *p = z->out;
|
||||||
|
@ -1639,7 +1639,7 @@ static int _m3dstbi__expand_png_palette(_m3dstbi__png *a, unsigned char *palette
|
||||||
|
|
||||||
static int _m3dstbi__parse_png_file(_m3dstbi__png *z, int scan, int req_comp) {
|
static int _m3dstbi__parse_png_file(_m3dstbi__png *z, int scan, int req_comp) {
|
||||||
unsigned char palette[1024], pal_img_n = 0;
|
unsigned char palette[1024], pal_img_n = 0;
|
||||||
unsigned char has_trans = 0, tc[3];
|
unsigned char has_trans = 0, tc[3] = {};
|
||||||
_m3dstbi__uint16 tc16[3];
|
_m3dstbi__uint16 tc16[3];
|
||||||
_m3dstbi__uint32 ioff = 0, idata_limit = 0, i, pal_len = 0;
|
_m3dstbi__uint32 ioff = 0, idata_limit = 0, i, pal_len = 0;
|
||||||
int first = 1, k, interlace = 0, color = 0;
|
int first = 1, k, interlace = 0, color = 0;
|
||||||
|
@ -4350,7 +4350,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size
|
||||||
M3D_INDEX last, *vrtxidx = NULL, *mtrlidx = NULL, *tmapidx = NULL, *skinidx = NULL;
|
M3D_INDEX last, *vrtxidx = NULL, *mtrlidx = NULL, *tmapidx = NULL, *skinidx = NULL;
|
||||||
uint32_t idx, numcmap = 0, *cmap = NULL, numvrtx = 0, maxvrtx = 0, numtmap = 0, maxtmap = 0, numproc = 0;
|
uint32_t idx, numcmap = 0, *cmap = NULL, numvrtx = 0, maxvrtx = 0, numtmap = 0, maxtmap = 0, numproc = 0;
|
||||||
uint32_t numskin = 0, maxskin = 0, numstr = 0, maxt = 0, maxbone = 0, numgrp = 0, maxgrp = 0, *grpidx = NULL;
|
uint32_t numskin = 0, maxskin = 0, numstr = 0, maxt = 0, maxbone = 0, numgrp = 0, maxgrp = 0, *grpidx = NULL;
|
||||||
uint8_t *opa;
|
uint8_t *opa = nullptr;
|
||||||
m3dcd_t *cd;
|
m3dcd_t *cd;
|
||||||
m3dc_t *cmd;
|
m3dc_t *cmd;
|
||||||
m3dstr_t *str = NULL;
|
m3dstr_t *str = NULL;
|
||||||
|
|
|
@ -382,7 +382,12 @@ namespace glTF
|
||||||
{
|
{
|
||||||
friend struct Accessor;
|
friend struct Accessor;
|
||||||
|
|
||||||
Accessor& accessor;
|
// This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is:
|
||||||
|
// ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field]
|
||||||
|
protected:
|
||||||
|
Accessor &accessor;
|
||||||
|
|
||||||
|
private:
|
||||||
uint8_t* data;
|
uint8_t* data;
|
||||||
size_t elemSize, stride;
|
size_t elemSize, stride;
|
||||||
|
|
||||||
|
|
|
@ -389,12 +389,18 @@ struct Accessor : public Object {
|
||||||
class Indexer {
|
class Indexer {
|
||||||
friend struct Accessor;
|
friend struct Accessor;
|
||||||
|
|
||||||
|
// This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is:
|
||||||
|
// ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field]
|
||||||
|
protected:
|
||||||
Accessor &accessor;
|
Accessor &accessor;
|
||||||
|
|
||||||
|
private:
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
size_t elemSize, stride;
|
size_t elemSize, stride;
|
||||||
|
|
||||||
Indexer(Accessor &acc);
|
Indexer(Accessor &acc);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Accesses the i-th value as defined by the accessor
|
//! Accesses the i-th value as defined by the accessor
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
|
@ -636,9 +636,6 @@ private:
|
||||||
for (s32 i=0; i<amount; ++i)
|
for (s32 i=0; i<amount; ++i)
|
||||||
array[i] = old_array[i];
|
array[i] = old_array[i];
|
||||||
|
|
||||||
if (allocated < used)
|
|
||||||
used = allocated;
|
|
||||||
|
|
||||||
delete [] old_array;
|
delete [] old_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,11 +46,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_SPATIALSORT_H_INC
|
#define AI_SPATIALSORT_H_INC
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# pragma GCC system_header
|
#pragma GCC system_header
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <assimp/types.h>
|
#include <assimp/types.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
|
@ -62,10 +62,8 @@ namespace Assimp {
|
||||||
* time, with O(n) worst case complexity when all vertices lay on the plane. The plane is chosen
|
* time, with O(n) worst case complexity when all vertices lay on the plane. The plane is chosen
|
||||||
* so that it avoids common planes in usual data sets. */
|
* so that it avoids common planes in usual data sets. */
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
class ASSIMP_API SpatialSort
|
class ASSIMP_API SpatialSort {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SpatialSort();
|
SpatialSort();
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
|
@ -76,14 +74,12 @@ public:
|
||||||
* @param pNumPositions Number of vectors to expect in that array.
|
* @param pNumPositions Number of vectors to expect in that array.
|
||||||
* @param pElementOffset Offset in bytes from the beginning of one vector in memory
|
* @param pElementOffset Offset in bytes from the beginning of one vector in memory
|
||||||
* to the beginning of the next vector. */
|
* to the beginning of the next vector. */
|
||||||
SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions,
|
SpatialSort(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||||
unsigned int pElementOffset);
|
unsigned int pElementOffset);
|
||||||
|
|
||||||
/** Destructor */
|
/** Destructor */
|
||||||
~SpatialSort();
|
~SpatialSort();
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
|
/** Sets the input data for the SpatialSort. This replaces existing data, if any.
|
||||||
* The new data receives new indices in ascending order.
|
* The new data receives new indices in ascending order.
|
||||||
|
@ -97,17 +93,15 @@ public:
|
||||||
* required in order to use #FindPosition() or #GenerateMappingTable().
|
* required in order to use #FindPosition() or #GenerateMappingTable().
|
||||||
* If you don't finalize yet, you can use #Append() to add data from
|
* If you don't finalize yet, you can use #Append() to add data from
|
||||||
* other sources.*/
|
* other sources.*/
|
||||||
void Fill( const aiVector3D* pPositions, unsigned int pNumPositions,
|
void Fill(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||||
unsigned int pElementOffset,
|
unsigned int pElementOffset,
|
||||||
bool pFinalize = true);
|
bool pFinalize = true);
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
/** Same as #Fill(), except the method appends to existing data in the #SpatialSort. */
|
/** Same as #Fill(), except the method appends to existing data in the #SpatialSort. */
|
||||||
void Append( const aiVector3D* pPositions, unsigned int pNumPositions,
|
void Append(const aiVector3D *pPositions, unsigned int pNumPositions,
|
||||||
unsigned int pElementOffset,
|
unsigned int pElementOffset,
|
||||||
bool pFinalize = true);
|
bool pFinalize = true);
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
/** Finalize the spatial hash data structure. This can be useful after
|
/** Finalize the spatial hash data structure. This can be useful after
|
||||||
|
@ -123,8 +117,8 @@ public:
|
||||||
* @param poResults The container to store the indices of the found positions.
|
* @param poResults The container to store the indices of the found positions.
|
||||||
* Will be emptied by the call so it may contain anything.
|
* Will be emptied by the call so it may contain anything.
|
||||||
* @return An iterator to iterate over all vertices in the given area.*/
|
* @return An iterator to iterate over all vertices in the given area.*/
|
||||||
void FindPositions( const aiVector3D& pPosition, ai_real pRadius,
|
void FindPositions(const aiVector3D &pPosition, ai_real pRadius,
|
||||||
std::vector<unsigned int>& poResults) const;
|
std::vector<unsigned int> &poResults) const;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
/** Fills an array with indices of all positions identical to the given position. In
|
/** Fills an array with indices of all positions identical to the given position. In
|
||||||
|
@ -133,8 +127,8 @@ public:
|
||||||
* @param pPosition The position to look for vertices.
|
* @param pPosition The position to look for vertices.
|
||||||
* @param poResults The container to store the indices of the found positions.
|
* @param poResults The container to store the indices of the found positions.
|
||||||
* Will be emptied by the call so it may contain anything.*/
|
* Will be emptied by the call so it may contain anything.*/
|
||||||
void FindIdenticalPositions( const aiVector3D& pPosition,
|
void FindIdenticalPositions(const aiVector3D &pPosition,
|
||||||
std::vector<unsigned int>& poResults) const;
|
std::vector<unsigned int> &poResults) const;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------
|
||||||
/** Compute a table that maps each vertex ID referring to a spatially close
|
/** Compute a table that maps each vertex ID referring to a spatially close
|
||||||
|
@ -144,8 +138,8 @@ public:
|
||||||
* @param pRadius Maximal distance from the position a vertex may have to
|
* @param pRadius Maximal distance from the position a vertex may have to
|
||||||
* be counted in.
|
* be counted in.
|
||||||
* @return Number of unique vertices (n). */
|
* @return Number of unique vertices (n). */
|
||||||
unsigned int GenerateMappingTable(std::vector<unsigned int>& fill,
|
unsigned int GenerateMappingTable(std::vector<unsigned int> &fill,
|
||||||
ai_real pRadius) const;
|
ai_real pRadius) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
/** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */
|
||||||
|
@ -159,15 +153,17 @@ protected:
|
||||||
ai_real mDistance; ///< Distance of this vertex to the sorting plane
|
ai_real mDistance; ///< Distance of this vertex to the sorting plane
|
||||||
|
|
||||||
Entry() AI_NO_EXCEPT
|
Entry() AI_NO_EXCEPT
|
||||||
: mIndex( 999999999 ), mPosition(), mDistance( 99999. ) {
|
: mIndex(999999999),
|
||||||
|
mPosition(),
|
||||||
|
mDistance(99999.) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
Entry( unsigned int pIndex, const aiVector3D& pPosition, ai_real pDistance)
|
Entry(unsigned int pIndex, const aiVector3D &pPosition, ai_real pDistance) :
|
||||||
: mIndex( pIndex), mPosition( pPosition), mDistance( pDistance) {
|
mIndex(pIndex), mPosition(pPosition), mDistance(pDistance) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const Entry& e) const { return mDistance < e.mDistance; }
|
bool operator<(const Entry &e) const { return mDistance < e.mDistance; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// all positions, sorted by distance to the sorting plane
|
// all positions, sorted by distance to the sorting plane
|
||||||
|
|
|
@ -308,7 +308,10 @@ struct aiBone {
|
||||||
|
|
||||||
//! Copy constructor
|
//! Copy constructor
|
||||||
aiBone(const aiBone &other) :
|
aiBone(const aiBone &other) :
|
||||||
mName(other.mName), mNumWeights(other.mNumWeights), mWeights(nullptr), mOffsetMatrix(other.mOffsetMatrix) {
|
mName(other.mName),
|
||||||
|
mNumWeights(other.mNumWeights),
|
||||||
|
mWeights(nullptr),
|
||||||
|
mOffsetMatrix(other.mOffsetMatrix) {
|
||||||
if (other.mWeights && other.mNumWeights) {
|
if (other.mWeights && other.mNumWeights) {
|
||||||
mWeights = new aiVertexWeight[mNumWeights];
|
mWeights = new aiVertexWeight[mNumWeights];
|
||||||
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight));
|
||||||
|
|
|
@ -320,7 +320,7 @@ struct aiMetadata {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool Set( const std::string &key, const T &value ) {
|
inline bool Set(const std::string &key, const T &value) {
|
||||||
if (key.empty()) {
|
if (key.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,7 @@ SET( COMMON
|
||||||
unit/utStringUtils.cpp
|
unit/utStringUtils.cpp
|
||||||
unit/Common/uiScene.cpp
|
unit/Common/uiScene.cpp
|
||||||
unit/Common/utLineSplitter.cpp
|
unit/Common/utLineSplitter.cpp
|
||||||
|
unit/Common/utSpatialSort.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SET( IMPORTERS
|
SET( IMPORTERS
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2020, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/SpatialSort.h>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utSpatialSort : public ::testing::Test {
|
||||||
|
public
|
||||||
|
:
|
||||||
|
aiVector3D *vecs;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void SetUp() override {
|
||||||
|
::srand(static_cast<unsigned>(time(0)));
|
||||||
|
vecs = new aiVector3D[100];
|
||||||
|
for (size_t i = 0; i < 100; ++i) {
|
||||||
|
vecs[i].x = static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / 100));
|
||||||
|
vecs[i].y = static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / 100));
|
||||||
|
vecs[i].z = static_cast<float>(rand()) / (static_cast<float>(RAND_MAX / 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
delete[] vecs;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F( utSpatialSort, findIdenticalsTest ) {
|
||||||
|
SpatialSort sSort;
|
||||||
|
sSort.Fill(vecs, 100, sizeof(aiVector3D));
|
||||||
|
|
||||||
|
std::vector<unsigned int> indices;
|
||||||
|
sSort.FindIdenticalPositions(vecs[0], indices);
|
||||||
|
EXPECT_EQ(1u, indices.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utSpatialSort, findPositionsTest) {
|
||||||
|
SpatialSort sSort;
|
||||||
|
sSort.Fill(vecs, 100, sizeof(aiVector3D));
|
||||||
|
|
||||||
|
std::vector<unsigned int> indices;
|
||||||
|
sSort.FindPositions(vecs[0], 0.01f, indices);
|
||||||
|
EXPECT_EQ(1u, indices.size());
|
||||||
|
}
|
|
@ -210,13 +210,13 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) {
|
||||||
EXPECT_NE(nullptr, scene);
|
EXPECT_NE(nullptr, scene);
|
||||||
EXPECT_NE(nullptr, scene->mMetaData);
|
EXPECT_NE(nullptr, scene->mMetaData);
|
||||||
|
|
||||||
double factor(0.0);
|
float factor(0.0f);
|
||||||
scene->mMetaData->Get("UnitScaleFactor", factor);
|
scene->mMetaData->Get("UnitScaleFactor", factor);
|
||||||
EXPECT_DOUBLE_EQ(500.0, factor);
|
EXPECT_EQ(500.0f, factor);
|
||||||
|
|
||||||
scene->mMetaData->Set("UnitScaleFactor", factor * 2);
|
scene->mMetaData->Set("UnitScaleFactor", factor * 2.0f);
|
||||||
scene->mMetaData->Get("UnitScaleFactor", factor);
|
scene->mMetaData->Get("UnitScaleFactor", factor);
|
||||||
EXPECT_DOUBLE_EQ(1000.0, factor);
|
EXPECT_EQ(1000.0f, factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
|
TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue