FIX: IrrMesh lightmap scale factor is imported correctly now.
FIX: aiProcess_TransformUVCoords tried to transform untransformed channels, and 'he' changed their order from time to time. FIX: Viewer displays lightmap with scaling factor correctly now. Further work on documentation, material doc is WIP for the moment. Some improvements to fast_atof. Updating makeifle.mingw to reflect my new boost location (arg, too lazy to make it better ...). git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@413 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
@@ -50,42 +50,35 @@ inline void SetGenericProperty(std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& value, bool* bWasExisting = NULL)
|
||||
{
|
||||
ai_assert(NULL != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typedef std::map< unsigned int, T > GenericPropertyMap;
|
||||
typedef std::pair< unsigned int, T > GenericPair;
|
||||
|
||||
uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename GenericPropertyMap::iterator it = list.find(hash);
|
||||
if (it == list.end())
|
||||
{
|
||||
if (bWasExisting)*bWasExisting = false;
|
||||
list.insert(GenericPair( hash, value ));
|
||||
typename std::map<unsigned int, T>::iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
if (bWasExisting)
|
||||
*bWasExisting = false;
|
||||
list.insert(std::pair<unsigned int, T>( hash, value ));
|
||||
return;
|
||||
}
|
||||
(*it).second = value;
|
||||
if (bWasExisting)*bWasExisting = true;
|
||||
if (bWasExisting)
|
||||
*bWasExisting = true;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <class T>
|
||||
inline const T& GetGenericProperty(const std::map< unsigned int, T >& list,
|
||||
const char* szName, const T& errorReturn)
|
||||
{
|
||||
ai_assert(NULL != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typedef std::map< unsigned int, T > GenericPropertyMap;
|
||||
typedef std::pair< unsigned int, T > GenericPair;
|
||||
|
||||
uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename GenericPropertyMap::const_iterator it = list.find(hash);
|
||||
if (it == list.end())return errorReturn;
|
||||
typename std::map<unsigned int, T>::const_iterator it = list.find(hash);
|
||||
if (it == list.end())
|
||||
return errorReturn;
|
||||
|
||||
return (*it).second;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Special version for pointer types - they will be deleted when replaced with another value
|
||||
// passing NULL removes the whole property
|
||||
@@ -94,29 +87,25 @@ inline void SetGenericPropertyPtr(std::map< unsigned int, T* >& list,
|
||||
const char* szName, T* value, bool* bWasExisting = NULL)
|
||||
{
|
||||
ai_assert(NULL != szName);
|
||||
const uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typedef std::map< unsigned int, T* > GenericPropertyMap;
|
||||
typedef std::pair< unsigned int, T* > GenericPair;
|
||||
|
||||
uint32_t hash = SuperFastHash(szName);
|
||||
|
||||
typename GenericPropertyMap::iterator it = list.find(hash);
|
||||
if (it == list.end())
|
||||
{
|
||||
if (bWasExisting)*bWasExisting = false;
|
||||
list.insert(GenericPair( hash, value ));
|
||||
typename std::map<unsigned int, T*>::iterator it = list.find(hash);
|
||||
if (it == list.end()) {
|
||||
if (bWasExisting)
|
||||
*bWasExisting = false;
|
||||
|
||||
list.insert(std::pair<unsigned int,T*>( hash, value ));
|
||||
return;
|
||||
}
|
||||
if ((*it).second != value)
|
||||
{
|
||||
if ((*it).second != value) {
|
||||
delete (*it).second;
|
||||
(*it).second = value;
|
||||
}
|
||||
if (!value)
|
||||
{
|
||||
if (!value) {
|
||||
list.erase(it);
|
||||
}
|
||||
if (bWasExisting)*bWasExisting = true;
|
||||
if (bWasExisting)
|
||||
*bWasExisting = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -210,6 +210,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
|
||||
|
||||
matFlags = 0; // zero output flags
|
||||
int cnt = 0; // number of used texture channels
|
||||
unsigned int nd = 0;
|
||||
|
||||
// Continue reading from the file
|
||||
while (reader->read())
|
||||
@@ -363,7 +364,7 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
else if (prop.name == "Texture2")
|
||||
else if (prop.name == "Texture2" && cnt == 1)
|
||||
{
|
||||
// 2-layer material lightmapped?
|
||||
if (matFlags & AI_IRRMESH_MAT_lightmap) {
|
||||
@@ -388,25 +389,27 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
|
||||
++cnt;
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(1));
|
||||
++nd;
|
||||
|
||||
// set the corresponding material flag
|
||||
matFlags |= AI_IRRMESH_EXTRA_2ND_TEXTURE;
|
||||
}
|
||||
else DefaultLogger::get()->warn("IRRmat: Skipping second texture");
|
||||
}
|
||||
else if (prop.name == "Texture3")
|
||||
|
||||
else if (prop.name == "Texture3" && cnt == 2)
|
||||
{
|
||||
// Irrlicht does not seem to use these channels.
|
||||
++cnt;
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_UNKNOWN(0));
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(nd+1));
|
||||
}
|
||||
else if (prop.name == "Texture4" )
|
||||
else if (prop.name == "Texture4" && cnt == 3)
|
||||
{
|
||||
// Irrlicht does not seem to use these channels.
|
||||
++cnt;
|
||||
s.Set(prop.value);
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_UNKNOWN(1));
|
||||
mat->AddProperty(&s,AI_MATKEY_TEXTURE_DIFFUSE(nd+2));
|
||||
}
|
||||
|
||||
// Texture mapping options
|
||||
@@ -435,14 +438,14 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
|
||||
else if (prop.name == "TextureWrap3" && cnt >= 3)
|
||||
{
|
||||
int map = ConvertMappingMode(prop.value);
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_UNKNOWN(0));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_UNKNOWN(0));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(nd+1));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(nd+1));
|
||||
}
|
||||
else if (prop.name == "TextureWrap4" && cnt >= 4)
|
||||
{
|
||||
int map = ConvertMappingMode(prop.value);
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_UNKNOWN(1));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_UNKNOWN(1));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_U_DIFFUSE(nd+2));
|
||||
mat->AddProperty(&map,1,AI_MATKEY_MAPPINGMODE_V_DIFFUSE(nd+2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,25 +458,24 @@ aiMaterial* IrrlichtBase::ParseMaterial(unsigned int& matFlags)
|
||||
/* IRR */ !ASSIMP_stricmp(reader->getNodeName(),"attributes"))
|
||||
{
|
||||
// Now process lightmapping flags
|
||||
// We should have at least one texture, however
|
||||
// if there are multiple textures we assign the
|
||||
// lightmap settings to the last texture.
|
||||
// We should have at least one textur to do that ..
|
||||
if (cnt && matFlags & AI_IRRMESH_MAT_lightmap)
|
||||
{
|
||||
float f = 1.f;
|
||||
unsigned int unmasked = matFlags&~AI_IRRMESH_MAT_lightmap;
|
||||
|
||||
// Additive lightmap?
|
||||
int op = (matFlags & AI_IRRMESH_MAT_lightmap_add
|
||||
int op = (unmasked & AI_IRRMESH_MAT_lightmap_add
|
||||
? aiTextureOp_Add : aiTextureOp_Multiply);
|
||||
|
||||
// Handle Irrlicht's lightmapping scaling factor
|
||||
if (matFlags & AI_IRRMESH_MAT_lightmap_m2 ||
|
||||
matFlags & AI_IRRMESH_MAT_lightmap_light_m2)
|
||||
if (unmasked & AI_IRRMESH_MAT_lightmap_m2 ||
|
||||
unmasked & AI_IRRMESH_MAT_lightmap_light_m2)
|
||||
{
|
||||
f = 2.f;
|
||||
}
|
||||
else if (matFlags & AI_IRRMESH_MAT_lightmap_m4 ||
|
||||
matFlags & AI_IRRMESH_MAT_lightmap_light_m4)
|
||||
else if (unmasked & AI_IRRMESH_MAT_lightmap_m4 ||
|
||||
unmasked & AI_IRRMESH_MAT_lightmap_light_m4)
|
||||
{
|
||||
f = 4.f;
|
||||
}
|
||||
|
||||
@@ -101,8 +101,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
{
|
||||
out -= rounded*(float)AI_MATH_PI;
|
||||
|
||||
sprintf(szTemp,"Texture coordinate rotation %f can "
|
||||
"be simplified to %f",info.mRotation,out);
|
||||
sprintf(szTemp,"Texture coordinate rotation %f can be simplified to %f",info.mRotation,out);
|
||||
DefaultLogger::get()->info(szTemp);
|
||||
}
|
||||
|
||||
@@ -120,36 +119,29 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
* type (e.g. if mirroring is active there IS a difference between
|
||||
* offset 2 and 3)
|
||||
*/
|
||||
if ((rounded = (int)info.mTranslation.x))
|
||||
{
|
||||
if ((rounded = (int)info.mTranslation.x)) {
|
||||
float out;
|
||||
szTemp[0] = 0;
|
||||
if (aiTextureMapMode_Wrap == info.mapU)
|
||||
{
|
||||
if (aiTextureMapMode_Wrap == info.mapU) {
|
||||
// Wrap - simple take the fraction of the field
|
||||
out = info.mTranslation.x-(float)rounded;
|
||||
sprintf(szTemp,"[w] UV U offset %f can "
|
||||
"be simplified to %f",info.mTranslation.x,out);
|
||||
sprintf(szTemp,"[w] UV U offset %f can be simplified to %f",info.mTranslation.x,out);
|
||||
}
|
||||
else if (aiTextureMapMode_Mirror == info.mapU && 1 != rounded)
|
||||
{
|
||||
else if (aiTextureMapMode_Mirror == info.mapU && 1 != rounded) {
|
||||
// Mirror
|
||||
if (rounded % 2)rounded--;
|
||||
if (rounded % 2)
|
||||
rounded--;
|
||||
out = info.mTranslation.x-(float)rounded;
|
||||
|
||||
sprintf(szTemp,"[m/d] UV U offset %f can "
|
||||
"be simplified to %f",info.mTranslation.x,out);
|
||||
sprintf(szTemp,"[m/d] UV U offset %f can be simplified to %f",info.mTranslation.x,out);
|
||||
}
|
||||
else if (aiTextureMapMode_Clamp == info.mapU || aiTextureMapMode_Decal == info.mapU)
|
||||
{
|
||||
else if (aiTextureMapMode_Clamp == info.mapU || aiTextureMapMode_Decal == info.mapU) {
|
||||
// Clamp - translations beyond 1,1 are senseless
|
||||
sprintf(szTemp,"[c] UV U offset %f can "
|
||||
"be clamped to 1.0f",info.mTranslation.x);
|
||||
sprintf(szTemp,"[c] UV U offset %f can be clamped to 1.0f",info.mTranslation.x);
|
||||
|
||||
out = 1.f;
|
||||
}
|
||||
if (szTemp[0])
|
||||
{
|
||||
if (szTemp[0]) {
|
||||
DefaultLogger::get()->info(szTemp);
|
||||
info.mTranslation.x = out;
|
||||
}
|
||||
@@ -160,36 +152,29 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
* type (e.g. if mirroring is active there IS a difference between
|
||||
* offset 2 and 3)
|
||||
*/
|
||||
if ((rounded = (int)info.mTranslation.y))
|
||||
{
|
||||
if ((rounded = (int)info.mTranslation.y)) {
|
||||
float out;
|
||||
szTemp[0] = 0;
|
||||
if (aiTextureMapMode_Wrap == info.mapV)
|
||||
{
|
||||
if (aiTextureMapMode_Wrap == info.mapV) {
|
||||
// Wrap - simple take the fraction of the field
|
||||
out = info.mTranslation.y-(float)rounded;
|
||||
sprintf(szTemp,"[w] UV V offset %f can "
|
||||
"be simplified to %f",info.mTranslation.y,out);
|
||||
sprintf(szTemp,"[w] UV V offset %f can be simplified to %f",info.mTranslation.y,out);
|
||||
}
|
||||
else if (aiTextureMapMode_Mirror == info.mapV && 1 != rounded)
|
||||
{
|
||||
else if (aiTextureMapMode_Mirror == info.mapV && 1 != rounded) {
|
||||
// Mirror
|
||||
if (rounded % 2)rounded--;
|
||||
if (rounded % 2)
|
||||
rounded--;
|
||||
out = info.mTranslation.x-(float)rounded;
|
||||
|
||||
sprintf(szTemp,"[m/d] UV V offset %f can "
|
||||
"be simplified to %f",info.mTranslation.y,out);
|
||||
sprintf(szTemp,"[m/d] UV V offset %f can be simplified to %f",info.mTranslation.y,out);
|
||||
}
|
||||
else if (aiTextureMapMode_Clamp == info.mapV || aiTextureMapMode_Decal == info.mapV)
|
||||
{
|
||||
else if (aiTextureMapMode_Clamp == info.mapV || aiTextureMapMode_Decal == info.mapV) {
|
||||
// Clamp - translations beyond 1,1 are senseless
|
||||
sprintf(szTemp,"[c] UV V offset %f can"
|
||||
"be clamped to 1.0f",info.mTranslation.y);
|
||||
sprintf(szTemp,"[c] UV V offset %f canbe clamped to 1.0f",info.mTranslation.y);
|
||||
|
||||
out = 1.f;
|
||||
}
|
||||
if (szTemp[0])
|
||||
{
|
||||
if (szTemp[0]) {
|
||||
DefaultLogger::get()->info(szTemp);
|
||||
info.mTranslation.y = out;
|
||||
}
|
||||
@@ -201,9 +186,7 @@ void TextureTransformStep::PreProcessUVTransform(STransformVecInfo& info)
|
||||
void UpdateUVIndex(const std::list<TTUpdateInfo>& l, unsigned int n)
|
||||
{
|
||||
// Don't set if == 0 && wasn't set before
|
||||
for (std::list<TTUpdateInfo>::const_iterator it = l.begin();
|
||||
it != l.end(); ++it)
|
||||
{
|
||||
for (std::list<TTUpdateInfo>::const_iterator it = l.begin();it != l.end(); ++it) {
|
||||
const TTUpdateInfo& info = *it;
|
||||
|
||||
if (info.directShortcut)
|
||||
@@ -241,14 +224,13 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
typedef std::list<STransformVecInfo> MeshTrafoList;
|
||||
std::vector<MeshTrafoList> meshLists(pScene->mNumMeshes);
|
||||
|
||||
for (unsigned int i = 0; i < pScene->mNumMaterials;++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < pScene->mNumMaterials;++i) {
|
||||
|
||||
aiMaterial* mat = pScene->mMaterials[i];
|
||||
for (unsigned int a = 0; a < mat->mNumProperties;++a)
|
||||
{
|
||||
for (unsigned int a = 0; a < mat->mNumProperties;++a) {
|
||||
|
||||
aiMaterialProperty* prop = mat->mProperties[a];
|
||||
if (!::strcmp( prop->mKey.data, "$tex.file"))
|
||||
{
|
||||
if (!::strcmp( prop->mKey.data, "$tex.file")) {
|
||||
STransformVecInfo info;
|
||||
|
||||
// Setup a shortcut structure to allow for a fast updating
|
||||
@@ -313,15 +295,14 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
// Find out whether this material is used by more than
|
||||
// one mesh. This will make our task much, much more difficult!
|
||||
unsigned int cnt = 0;
|
||||
for (unsigned int n = 0; n < pScene->mNumMeshes;++n)
|
||||
{
|
||||
for (unsigned int n = 0; n < pScene->mNumMeshes;++n) {
|
||||
if (pScene->mMeshes[n]->mMaterialIndex == i)
|
||||
++cnt;
|
||||
}
|
||||
|
||||
if (!cnt)continue;
|
||||
else if (1 != cnt)
|
||||
{
|
||||
if (!cnt)
|
||||
continue;
|
||||
else if (1 != cnt) {
|
||||
// This material is referenced by more than one mesh!
|
||||
// So we need to make sure the UV index for the texture
|
||||
// is identical for each of it ...
|
||||
@@ -329,16 +310,14 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
}
|
||||
|
||||
// Get all coresponding meshes
|
||||
for (unsigned int n = 0; n < pScene->mNumMeshes;++n)
|
||||
{
|
||||
for (unsigned int n = 0; n < pScene->mNumMeshes;++n) {
|
||||
aiMesh* mesh = pScene->mMeshes[n];
|
||||
if (mesh->mMaterialIndex != i || !mesh->mTextureCoords[0]) continue;
|
||||
if (mesh->mMaterialIndex != i || !mesh->mTextureCoords[0])
|
||||
continue;
|
||||
|
||||
unsigned int uv = info.uvIndex;
|
||||
if (!mesh->mTextureCoords[uv])
|
||||
{
|
||||
// If the requested UV index is not available,
|
||||
// take the first one instead.
|
||||
if (!mesh->mTextureCoords[uv]) {
|
||||
// If the requested UV index is not available, take the first one instead.
|
||||
uv = 0;
|
||||
}
|
||||
|
||||
@@ -350,15 +329,15 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
MeshTrafoList::iterator it;
|
||||
|
||||
// Check whether we have this transform setup already
|
||||
for (it = meshLists[n].begin();it != meshLists[n].end(); ++it)
|
||||
{
|
||||
for (it = meshLists[n].begin();it != meshLists[n].end(); ++it) {
|
||||
|
||||
if ((*it) == info && (*it).uvIndex == uv) {
|
||||
(*it).updateList.push_back(update);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (it == meshLists[n].end())
|
||||
{
|
||||
|
||||
if (it == meshLists[n].end()) {
|
||||
meshLists[n].push_back(info);
|
||||
meshLists[n].back().uvIndex = uv;
|
||||
meshLists[n].back().updateList.push_back(update);
|
||||
@@ -373,66 +352,67 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
|
||||
// Now process all meshes. Important: we don't remove unreferenced UV channels.
|
||||
// This is a job for the RemoveUnreferencedData-Step.
|
||||
for (unsigned int q = 0; q < pScene->mNumMeshes;++q)
|
||||
{
|
||||
for (unsigned int q = 0; q < pScene->mNumMeshes;++q) {
|
||||
|
||||
aiMesh* mesh = pScene->mMeshes[q];
|
||||
MeshTrafoList& trafo = meshLists[q];
|
||||
|
||||
inChannels += mesh->GetNumUVChannels();
|
||||
|
||||
if (!mesh->mTextureCoords[0] || trafo.empty() ||
|
||||
trafo.size() == 1 && trafo.begin()->IsUntransformed())
|
||||
{
|
||||
if (!mesh->mTextureCoords[0] || trafo.empty() || trafo.size() == 1 && trafo.begin()->IsUntransformed()) {
|
||||
outChannels += mesh->GetNumUVChannels();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Move untransformed UV channels to the first
|
||||
// position in the list .... except if we need
|
||||
// a new locked index which should be as small as possible
|
||||
bool veto = false;
|
||||
// Move untransformed UV channels to the first position in the list ....
|
||||
// except if we need a new locked index which should be as small as possible
|
||||
bool veto = false, need = false;
|
||||
unsigned int cnt = 0;
|
||||
unsigned int untransformed = 0;
|
||||
|
||||
MeshTrafoList::iterator it,it2;
|
||||
for (it = trafo.begin();it != trafo.end(); ++it,++cnt)
|
||||
{
|
||||
if ((*it).lockedPos == AI_TT_UV_IDX_LOCK_TBD)
|
||||
{
|
||||
for (it = trafo.begin(), it2;it != trafo.end(); ++it,++cnt) {
|
||||
|
||||
if (!(*it).IsUntransformed())
|
||||
need = true;
|
||||
|
||||
if ((*it).lockedPos == AI_TT_UV_IDX_LOCK_TBD) {
|
||||
// Lock this index and make sure it won't be changed
|
||||
(*it).lockedPos = cnt;
|
||||
veto = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!veto && it != trafo.begin() && (*it).IsUntransformed())
|
||||
{
|
||||
trafo.push_front((*it));
|
||||
if (!veto && it != trafo.begin() && (*it).IsUntransformed()) {
|
||||
for (it2 = trafo.begin();it2 != it; ++it2) {
|
||||
if (!(*it2).IsUntransformed())
|
||||
break;
|
||||
}
|
||||
trafo.insert(it2,*it);
|
||||
trafo.erase(it);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!need)
|
||||
continue;
|
||||
|
||||
// Find all that are not at their 'locked' position
|
||||
// and move them to it. Conflicts are possible but
|
||||
// quite unlikely.
|
||||
// Find all that are not at their 'locked' position and move them to it.
|
||||
// Conflicts are possible but quite unlikely.
|
||||
cnt = 0;
|
||||
for (it = trafo.begin();it != trafo.end(); ++it,++cnt)
|
||||
{
|
||||
if ((*it).lockedPos != AI_TT_UV_IDX_LOCK_NONE && (*it).lockedPos != cnt)
|
||||
{
|
||||
for (it = trafo.begin();it != trafo.end(); ++it,++cnt) {
|
||||
if ((*it).lockedPos != AI_TT_UV_IDX_LOCK_NONE && (*it).lockedPos != cnt) {
|
||||
it2 = trafo.begin();unsigned int t = 0;
|
||||
while (t != (*it).lockedPos)++it2;
|
||||
while (t != (*it).lockedPos)
|
||||
++it2;
|
||||
|
||||
if ((*it2).lockedPos != AI_TT_UV_IDX_LOCK_NONE)
|
||||
{
|
||||
DefaultLogger::get()->error("Channel mismatch, can't compute all transformations properly");
|
||||
if ((*it2).lockedPos != AI_TT_UV_IDX_LOCK_NONE) {
|
||||
DefaultLogger::get()->error("Channel mismatch, can't compute all transformations properly [design bug]");
|
||||
continue;
|
||||
}
|
||||
|
||||
std::swap(*it2,*it);
|
||||
if ((*it).lockedPos == untransformed)untransformed = cnt;
|
||||
if ((*it).lockedPos == untransformed)
|
||||
untransformed = cnt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,9 +425,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
for (it = trafo.begin();it != trafo.end(); ++it)
|
||||
ref[(*it).uvIndex] = true;
|
||||
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n)
|
||||
{
|
||||
if (ref[n])continue;
|
||||
for (unsigned int n = 0; n < AI_MAX_NUMBER_OF_TEXTURECOORDS;++n) {
|
||||
if (ref[n])
|
||||
continue;
|
||||
trafo.push_back(STransformVecInfo());
|
||||
trafo.back().uvIndex = n;
|
||||
}
|
||||
@@ -456,10 +436,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
// The unimportant ones are at the end of the list, so
|
||||
// it shouldn't be too worse if we remove them.
|
||||
unsigned int size = (unsigned int)trafo.size();
|
||||
if (size > AI_MAX_NUMBER_OF_TEXTURECOORDS)
|
||||
{
|
||||
if (!DefaultLogger::isNullLogger())
|
||||
{
|
||||
if (size > AI_MAX_NUMBER_OF_TEXTURECOORDS) {
|
||||
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
::sprintf(buffer,"%i UV channels required but just %i available",
|
||||
trafo.size(),AI_MAX_NUMBER_OF_TEXTURECOORDS);
|
||||
|
||||
@@ -476,10 +455,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
// Now continue and generate the output channels. Channels
|
||||
// that we're not going to need later can be overridden.
|
||||
it = trafo.begin();
|
||||
for (unsigned int n = 0; n < trafo.size();++n,++it)
|
||||
{
|
||||
if (n >= size)
|
||||
{
|
||||
for (unsigned int n = 0; n < trafo.size();++n,++it) {
|
||||
|
||||
if (n >= size) {
|
||||
// Try to use an untransformed channel for all channels we threw over board
|
||||
UpdateUVIndex((*it).updateList,untransformed);
|
||||
continue;
|
||||
@@ -488,8 +466,7 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
outChannels++;
|
||||
|
||||
// Write to the log
|
||||
if (!DefaultLogger::isNullLogger())
|
||||
{
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
sprintf(buffer,"Mesh %i, channel %i: t(%.3f,%.3f), s(%.3f,%.3f), r(%.3f), %s%s",
|
||||
q,n,
|
||||
(*it).mTranslation.x,
|
||||
@@ -504,11 +481,11 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
}
|
||||
|
||||
// Check whether we need a new buffer here
|
||||
if (mesh->mTextureCoords[n])
|
||||
{
|
||||
if (mesh->mTextureCoords[n]) {
|
||||
|
||||
it2 = it;++it2;
|
||||
for (unsigned int m = n+1; m < size;++m, ++it2)
|
||||
{
|
||||
for (unsigned int m = n+1; m < size;++m, ++it2) {
|
||||
|
||||
if ((*it2).uvIndex == n){
|
||||
it2 = trafo.begin();
|
||||
break;
|
||||
@@ -533,11 +510,11 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
end = dest + mesh->mNumVertices;
|
||||
|
||||
// Build a transformation matrix and transform all UV coords with it
|
||||
if (!(*it).IsUntransformed())
|
||||
{
|
||||
if (!(*it).IsUntransformed()) {
|
||||
const aiVector2D& trl = (*it).mTranslation;
|
||||
const aiVector2D& scl = (*it).mScaling;
|
||||
|
||||
// fixme: simplify ..
|
||||
++transformedChannels;
|
||||
aiMatrix3x3 matrix;
|
||||
|
||||
@@ -555,7 +532,7 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
m5.a3 += trl.x; m5.b3 += trl.y;
|
||||
matrix = m2 * m4 * matrix * m3 * m5;
|
||||
|
||||
for (src = dest; src != end; ++src) {
|
||||
for (src = dest; src != end; ++src) { /* manual homogenious divide */
|
||||
src->z = 1.f;
|
||||
*src = matrix * *src;
|
||||
src->x /= src->z;
|
||||
@@ -570,10 +547,9 @@ void TextureTransformStep::Execute( aiScene* pScene)
|
||||
}
|
||||
|
||||
// Print some detailled statistics into the log
|
||||
if (!DefaultLogger::isNullLogger())
|
||||
{
|
||||
if (transformedChannels)
|
||||
{
|
||||
if (!DefaultLogger::isNullLogger()) {
|
||||
|
||||
if (transformedChannels) {
|
||||
::sprintf(buffer,"TransformUVCoordsProcess end: %i output channels (in: %i, modified: %i)",
|
||||
outChannels,inChannels,transformedChannels);
|
||||
|
||||
|
||||
@@ -141,11 +141,14 @@ inline uint8_t HexOctetToDecimal(const char* in)
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline int strtol10s( const char* in, const char** out=0)
|
||||
{
|
||||
bool bNeg = false;
|
||||
if ('-' == *in){++in;bNeg = true;}
|
||||
if ('+' == *in)++in;
|
||||
bool inv = (*in=='-');
|
||||
if (inv || *in=='+')
|
||||
++in;
|
||||
|
||||
int value = strtol10(in,out);
|
||||
if (bNeg)value = -value;
|
||||
if (inv) {
|
||||
value = -value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -218,14 +221,13 @@ inline uint64_t strtol10_64( const char* in, const char** out=0, unsigned int* m
|
||||
// ------------------------------------------------------------------------------------
|
||||
inline const char* fast_atof_move( const char* c, float& out)
|
||||
{
|
||||
const char *t;
|
||||
float f;
|
||||
|
||||
bool inv = (*c=='-');
|
||||
if (inv || *c=='+')
|
||||
++c;
|
||||
|
||||
f = (float) strtol10_64 ( c, &c );
|
||||
f = (float) strtol10_64 ( c, &c);
|
||||
if (*c == '.' || (c[0] == ',' && (c[1] >= '0' || c[1] <= '9'))) // allow for commas, too
|
||||
{
|
||||
++c;
|
||||
@@ -239,12 +241,10 @@ inline const char* fast_atof_move( const char* c, float& out)
|
||||
// number of digits to be read. AI_FAST_ATOF_RELAVANT_DECIMALS can be a value between
|
||||
// 1 and 15.
|
||||
unsigned int diff = AI_FAST_ATOF_RELAVANT_DECIMALS;
|
||||
double pl = (double) strtol10_64 ( c, &t, &diff );
|
||||
double pl = (double) strtol10_64 ( c, &c, &diff );
|
||||
|
||||
pl *= fast_atof_table[diff];
|
||||
|
||||
f += (float)pl;
|
||||
c = t;
|
||||
}
|
||||
|
||||
// A major 'E' must be allowed. Necessary for proper reading of some DXF files.
|
||||
@@ -256,7 +256,7 @@ inline const char* fast_atof_move( const char* c, float& out)
|
||||
if (einv || *c=='+')
|
||||
++c;
|
||||
|
||||
float exp = (float)strtol10(c, &c);
|
||||
float exp = (float)strtol10_64(c, &c);
|
||||
if (einv)
|
||||
exp *= -1.0f;
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ ifeq ($(NOBOOST),1)
|
||||
DEFINEFLAGS += -DASSIMP_BUILD_BOOST_WORKAROUND
|
||||
# NAMESUFFIX += -noboost
|
||||
else
|
||||
INCLUDEFLAGS += -I"C:/Program Files/boost/boost_1_35_0"
|
||||
# adjust this manually if your boost is stored elsewhere
|
||||
INCLUDEFLAGS += -I"C:/Program Files/boost/boost_1_38"
|
||||
endif
|
||||
|
||||
# Setup environment for st build
|
||||
|
||||
Reference in New Issue
Block a user