Merge branch 'master' of https://github.com/assimp/assimp
commit
814d2e7821
|
@ -186,15 +186,14 @@ void Discreet3DSImporter::InternReadFile( const std::string& pFile,
|
||||||
// internal verbose representation. Finally compute normal
|
// internal verbose representation. Finally compute normal
|
||||||
// vectors from the smoothing groups we read from the
|
// vectors from the smoothing groups we read from the
|
||||||
// file.
|
// file.
|
||||||
for (std::vector<D3DS::Mesh>::iterator i = mScene->mMeshes.begin(),
|
for (auto &mesh : mScene->mMeshes) {
|
||||||
end = mScene->mMeshes.end(); i != end;++i) {
|
if (mesh.mFaces.size() > 0 && mesh.mPositions.size() == 0) {
|
||||||
if ((*i).mFaces.size() > 0 && (*i).mPositions.size() == 0) {
|
|
||||||
delete mScene;
|
delete mScene;
|
||||||
throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile);
|
throw DeadlyImportError("3DS file contains faces but no vertices: " + pFile);
|
||||||
}
|
}
|
||||||
CheckIndices(*i);
|
CheckIndices(mesh);
|
||||||
MakeUnique (*i);
|
MakeUnique (mesh);
|
||||||
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(*i);
|
ComputeNormalsWithSmoothingsGroups<D3DS::Face>(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace all occurrences of the default material with a
|
// Replace all occurrences of the default material with a
|
||||||
|
|
|
@ -225,17 +225,13 @@ void ASEImporter::InternReadFile( const std::string& pFile,
|
||||||
+ mParser->m_vCameras.size() + mParser->m_vDummies.size());
|
+ mParser->m_vCameras.size() + mParser->m_vDummies.size());
|
||||||
|
|
||||||
// Lights
|
// Lights
|
||||||
for (std::vector<ASE::Light>::iterator it = mParser->m_vLights.begin(),
|
for (auto &light : mParser->m_vLights)nodes.push_back(&light);
|
||||||
end = mParser->m_vLights.end();it != end; ++it)nodes.push_back(&(*it));
|
|
||||||
// Cameras
|
// Cameras
|
||||||
for (std::vector<ASE::Camera>::iterator it = mParser->m_vCameras.begin(),
|
for (auto &camera : mParser->m_vCameras)nodes.push_back(&camera);
|
||||||
end = mParser->m_vCameras.end();it != end; ++it)nodes.push_back(&(*it));
|
|
||||||
// Meshes
|
// Meshes
|
||||||
for (std::vector<ASE::Mesh>::iterator it = mParser->m_vMeshes.begin(),
|
for (auto &mesh : mParser->m_vMeshes)nodes.push_back(&mesh);
|
||||||
end = mParser->m_vMeshes.end();it != end; ++it)nodes.push_back(&(*it));
|
|
||||||
// Dummies
|
// Dummies
|
||||||
for (std::vector<ASE::Dummy>::iterator it = mParser->m_vDummies.begin(),
|
for (auto &dummy : mParser->m_vDummies)nodes.push_back(&dummy);
|
||||||
end = mParser->m_vDummies.end();it != end; ++it)nodes.push_back(&(*it));
|
|
||||||
|
|
||||||
// build the final node graph
|
// build the final node graph
|
||||||
BuildNodes(nodes);
|
BuildNodes(nodes);
|
||||||
|
@ -657,8 +653,8 @@ void ASEImporter::BuildNodes(std::vector<BaseNode*>& nodes) {
|
||||||
ch->mParent = root;
|
ch->mParent = root;
|
||||||
|
|
||||||
// Change the transformation matrix of all nodes
|
// Change the transformation matrix of all nodes
|
||||||
for (std::vector<BaseNode*>::iterator it = nodes.begin(), end = nodes.end();it != end; ++it) {
|
for (BaseNode *node : nodes) {
|
||||||
aiMatrix4x4& m = (*it)->mTransform;
|
aiMatrix4x4& m = node->mTransform;
|
||||||
m.Transpose(); // row-order vs column-order
|
m.Transpose(); // row-order vs column-order
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,21 +276,20 @@ void ColladaLoader::ResolveNodeInstances( const ColladaParser& pParser, const Co
|
||||||
resolved.reserve(pNode->mNodeInstances.size());
|
resolved.reserve(pNode->mNodeInstances.size());
|
||||||
|
|
||||||
// ... and iterate through all nodes to be instanced as children of pNode
|
// ... and iterate through all nodes to be instanced as children of pNode
|
||||||
for (std::vector<Collada::NodeInstance>::const_iterator it = pNode->mNodeInstances.begin(),
|
for (const auto &nodeInst: pNode->mNodeInstances)
|
||||||
end = pNode->mNodeInstances.end(); it != end; ++it)
|
|
||||||
{
|
{
|
||||||
// find the corresponding node in the library
|
// find the corresponding node in the library
|
||||||
const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find((*it).mNode);
|
const ColladaParser::NodeLibrary::const_iterator itt = pParser.mNodeLibrary.find(nodeInst.mNode);
|
||||||
const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second;
|
const Collada::Node* nd = itt == pParser.mNodeLibrary.end() ? NULL : (*itt).second;
|
||||||
|
|
||||||
// FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632
|
// FIX for http://sourceforge.net/tracker/?func=detail&aid=3054873&group_id=226462&atid=1067632
|
||||||
// need to check for both name and ID to catch all. To avoid breaking valid files,
|
// need to check for both name and ID to catch all. To avoid breaking valid files,
|
||||||
// the workaround is only enabled when the first attempt to resolve the node has failed.
|
// the workaround is only enabled when the first attempt to resolve the node has failed.
|
||||||
if (!nd) {
|
if (!nd) {
|
||||||
nd = FindNode(pParser.mRootNode,(*it).mNode);
|
nd = FindNode(pParser.mRootNode, nodeInst.mNode);
|
||||||
}
|
}
|
||||||
if (!nd)
|
if (!nd)
|
||||||
DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + (*it).mNode);
|
DefaultLogger::get()->error("Collada: Unable to resolve reference to instanced node " + nodeInst.mNode);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// attach this node to the list of children
|
// attach this node to the list of children
|
||||||
|
@ -1320,11 +1319,10 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser,
|
||||||
// Fills materials from the collada material definitions
|
// Fills materials from the collada material definitions
|
||||||
void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pScene*/)
|
void ColladaLoader::FillMaterials( const ColladaParser& pParser, aiScene* /*pScene*/)
|
||||||
{
|
{
|
||||||
for (std::vector<std::pair<Collada::Effect*, aiMaterial*> >::iterator it = newMats.begin(),
|
for (auto &elem : newMats)
|
||||||
end = newMats.end(); it != end; ++it)
|
|
||||||
{
|
{
|
||||||
aiMaterial& mat = (aiMaterial&)*it->second;
|
aiMaterial& mat = (aiMaterial&)*elem.second;
|
||||||
Collada::Effect& effect = *it->first;
|
Collada::Effect& effect = *elem.first;
|
||||||
|
|
||||||
// resolve shading mode
|
// resolve shading mode
|
||||||
int shadeMode;
|
int shadeMode;
|
||||||
|
|
|
@ -324,8 +324,8 @@ D3MFZipArchive::D3MFZipArchive(IOSystem* pIOHandler, const std::string& rFile)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor.
|
// Destructor.
|
||||||
D3MFZipArchive::~D3MFZipArchive() {
|
D3MFZipArchive::~D3MFZipArchive() {
|
||||||
for( std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it ) {
|
for(auto &file : m_ArchiveMap) {
|
||||||
delete it->second;
|
delete file.second;
|
||||||
}
|
}
|
||||||
m_ArchiveMap.clear();
|
m_ArchiveMap.clear();
|
||||||
|
|
||||||
|
@ -398,8 +398,8 @@ void D3MFZipArchive::Close(IOStream *pFile) {
|
||||||
void D3MFZipArchive::getFileList(std::vector<std::string> &rFileList) {
|
void D3MFZipArchive::getFileList(std::vector<std::string> &rFileList) {
|
||||||
rFileList.clear();
|
rFileList.clear();
|
||||||
|
|
||||||
for(std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it) {
|
for(const auto &file : m_ArchiveMap) {
|
||||||
rFileList.push_back(it->first);
|
rFileList.push_back(file.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1062,8 +1062,8 @@ void Converter::GenerateTransformationNodeChain( const Model& model,
|
||||||
|
|
||||||
nd->mName.Set( name );
|
nd->mName.Set( name );
|
||||||
|
|
||||||
for ( size_t i = 0; i < TransformationComp_MAXIMUM; ++i ) {
|
for (const auto &transform : chain) {
|
||||||
nd->mTransformation = nd->mTransformation * chain[ i ];
|
nd->mTransformation = nd->mTransformation * transform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,8 +269,8 @@ Document::Document(const Parser& parser, const ImportSettings& settings)
|
||||||
, parser(parser)
|
, parser(parser)
|
||||||
{
|
{
|
||||||
// Cannot use array default initialization syntax because vc8 fails on it
|
// Cannot use array default initialization syntax because vc8 fails on it
|
||||||
for (unsigned int i = 0; i < sizeof(creationTimeStamp) / sizeof(creationTimeStamp[0]); ++i) {
|
for (auto &timeStamp : creationTimeStamp) {
|
||||||
creationTimeStamp[i] = 0;
|
timeStamp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadHeader();
|
ReadHeader();
|
||||||
|
|
|
@ -1372,8 +1372,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
/* Now iterate through all cameras and compute their final (horizontal) FOV
|
/* Now iterate through all cameras and compute their final (horizontal) FOV
|
||||||
*/
|
*/
|
||||||
for (std::vector<aiCamera*>::iterator it = cameras.begin(), end = cameras.end();it != end; ++it) {
|
for (aiCamera *cam : cameras) {
|
||||||
aiCamera* cam = *it;
|
|
||||||
|
|
||||||
// screen aspect could be missing
|
// screen aspect could be missing
|
||||||
if (cam->mAspect) {
|
if (cam->mAspect) {
|
||||||
|
|
|
@ -246,8 +246,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
||||||
apcMeshes.reserve(mLayers->size()*std::min(((unsigned int)mSurfaces->size()/2u), 1u));
|
apcMeshes.reserve(mLayers->size()*std::min(((unsigned int)mSurfaces->size()/2u), 1u));
|
||||||
|
|
||||||
unsigned int iDefaultSurface = UINT_MAX; // index of the default surface
|
unsigned int iDefaultSurface = UINT_MAX; // index of the default surface
|
||||||
for (LayerList::iterator lit = mLayers->begin(), lend = mLayers->end();lit != lend;++lit) {
|
for (LWO::Layer &layer : *mLayers) {
|
||||||
LWO::Layer& layer = *lit;
|
|
||||||
if (layer.skip)
|
if (layer.skip)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -909,12 +908,12 @@ void LWOImporter::LoadLWO2PolygonTags(unsigned int length)
|
||||||
template <class T>
|
template <class T>
|
||||||
VMapEntry* FindEntry(std::vector< T >& list,const std::string& name, bool perPoly)
|
VMapEntry* FindEntry(std::vector< T >& list,const std::string& name, bool perPoly)
|
||||||
{
|
{
|
||||||
for (typename std::vector< T >::iterator it = list.begin(), end = list.end();it != end; ++it) {
|
for (auto & elem : list) {
|
||||||
if ((*it).name == name) {
|
if (elem.name == name) {
|
||||||
if (!perPoly) {
|
if (!perPoly) {
|
||||||
DefaultLogger::get()->warn("LWO2: Found two VMAP sections with equal names");
|
DefaultLogger::get()->warn("LWO2: Found two VMAP sections with equal names");
|
||||||
}
|
}
|
||||||
return &(*it);
|
return &elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.push_back( T() );
|
list.push_back( T() );
|
||||||
|
@ -941,8 +940,8 @@ inline void CreateNewEntry(T& chan, unsigned int srcIdx)
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void CreateNewEntry(std::vector< T >& list, unsigned int srcIdx)
|
inline void CreateNewEntry(std::vector< T >& list, unsigned int srcIdx)
|
||||||
{
|
{
|
||||||
for (typename std::vector< T >::iterator it = list.begin(), end = list.end();it != end;++it) {
|
for (auto &elem : list) {
|
||||||
CreateNewEntry( *it, srcIdx );
|
CreateNewEntry( elem, srcIdx );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,8 +90,8 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
aiString s;
|
aiString s;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
for (TextureList::const_iterator it = in.begin(), end = in.end();it != end;++it) {
|
for (const auto &texture : in) {
|
||||||
if (!(*it).enabled || !(*it).bCanUse)
|
if (!texture.enabled || !texture.bCanUse)
|
||||||
continue;
|
continue;
|
||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
// channels if they're not there.
|
// channels if they're not there.
|
||||||
|
|
||||||
aiTextureMapping mapping;
|
aiTextureMapping mapping;
|
||||||
switch ((*it).mapMode)
|
switch (texture.mapMode)
|
||||||
{
|
{
|
||||||
case LWO::Texture::Planar:
|
case LWO::Texture::Planar:
|
||||||
mapping = aiTextureMapping_PLANE;
|
mapping = aiTextureMapping_PLANE;
|
||||||
|
@ -120,13 +120,13 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
break;
|
break;
|
||||||
case LWO::Texture::UV:
|
case LWO::Texture::UV:
|
||||||
{
|
{
|
||||||
if( UINT_MAX == (*it).mRealUVIndex ) {
|
if( UINT_MAX == texture.mRealUVIndex ) {
|
||||||
// We have no UV index for this texture, so we can't display it
|
// We have no UV index for this texture, so we can't display it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the UV source index
|
// add the UV source index
|
||||||
temp = (*it).mRealUVIndex;
|
temp = texture.mRealUVIndex;
|
||||||
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_UVWSRC(type,cur));
|
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_UVWSRC(type,cur));
|
||||||
|
|
||||||
mapping = aiTextureMapping_UV;
|
mapping = aiTextureMapping_UV;
|
||||||
|
@ -139,7 +139,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
if (mapping != aiTextureMapping_UV) {
|
if (mapping != aiTextureMapping_UV) {
|
||||||
// Setup the main axis
|
// Setup the main axis
|
||||||
aiVector3D v;
|
aiVector3D v;
|
||||||
switch ((*it).majorAxis) {
|
switch (texture.majorAxis) {
|
||||||
case Texture::AXIS_X:
|
case Texture::AXIS_X:
|
||||||
v = aiVector3D(1.f,0.f,0.f);
|
v = aiVector3D(1.f,0.f,0.f);
|
||||||
break;
|
break;
|
||||||
|
@ -156,8 +156,8 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
// Setup UV scalings for cylindric and spherical projections
|
// Setup UV scalings for cylindric and spherical projections
|
||||||
if (mapping == aiTextureMapping_CYLINDER || mapping == aiTextureMapping_SPHERE) {
|
if (mapping == aiTextureMapping_CYLINDER || mapping == aiTextureMapping_SPHERE) {
|
||||||
aiUVTransform trafo;
|
aiUVTransform trafo;
|
||||||
trafo.mScaling.x = (*it).wrapAmountW;
|
trafo.mScaling.x = texture.wrapAmountW;
|
||||||
trafo.mScaling.y = (*it).wrapAmountH;
|
trafo.mScaling.y = texture.wrapAmountH;
|
||||||
|
|
||||||
static_assert(sizeof(aiUVTransform)/sizeof(float) == 5, "sizeof(aiUVTransform)/sizeof(float) == 5");
|
static_assert(sizeof(aiUVTransform)/sizeof(float) == 5, "sizeof(aiUVTransform)/sizeof(float) == 5");
|
||||||
pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur));
|
pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur));
|
||||||
|
@ -171,7 +171,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
// find the corresponding clip (take the last one if multiple
|
// find the corresponding clip (take the last one if multiple
|
||||||
// share the same index)
|
// share the same index)
|
||||||
ClipList::iterator end = mClips.end(), candidate = end;
|
ClipList::iterator end = mClips.end(), candidate = end;
|
||||||
temp = (*it).mClipIdx;
|
temp = texture.mClipIdx;
|
||||||
for (ClipList::iterator clip = mClips.begin(); clip != end; ++clip) {
|
for (ClipList::iterator clip = mClips.begin(); clip != end; ++clip) {
|
||||||
if ((*clip).idx == temp) {
|
if ((*clip).idx == temp) {
|
||||||
candidate = clip;
|
candidate = clip;
|
||||||
|
@ -208,7 +208,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string ss = (*it).mFileName;
|
std::string ss = texture.mFileName;
|
||||||
if (!ss.length()) {
|
if (!ss.length()) {
|
||||||
DefaultLogger::get()->error("LWOB: Empty file name");
|
DefaultLogger::get()->error("LWOB: Empty file name");
|
||||||
continue;
|
continue;
|
||||||
|
@ -219,10 +219,10 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
pcMat->AddProperty(&s,AI_MATKEY_TEXTURE(type,cur));
|
pcMat->AddProperty(&s,AI_MATKEY_TEXTURE(type,cur));
|
||||||
|
|
||||||
// add the blend factor
|
// add the blend factor
|
||||||
pcMat->AddProperty<float>(&(*it).mStrength,1,AI_MATKEY_TEXBLEND(type,cur));
|
pcMat->AddProperty<float>(&texture.mStrength,1,AI_MATKEY_TEXBLEND(type,cur));
|
||||||
|
|
||||||
// add the blend operation
|
// add the blend operation
|
||||||
switch ((*it).blendType)
|
switch (texture.blendType)
|
||||||
{
|
{
|
||||||
case LWO::Texture::Normal:
|
case LWO::Texture::Normal:
|
||||||
case LWO::Texture::Multiply:
|
case LWO::Texture::Multiply:
|
||||||
|
@ -254,11 +254,11 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex
|
||||||
pcMat->AddProperty<int>((int*)&mapping,1,AI_MATKEY_MAPPING(type,cur));
|
pcMat->AddProperty<int>((int*)&mapping,1,AI_MATKEY_MAPPING(type,cur));
|
||||||
|
|
||||||
// add the u-wrapping
|
// add the u-wrapping
|
||||||
temp = (unsigned int)GetMapMode((*it).wrapModeWidth);
|
temp = (unsigned int)GetMapMode(texture.wrapModeWidth);
|
||||||
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_MAPPINGMODE_U(type,cur));
|
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_MAPPINGMODE_U(type,cur));
|
||||||
|
|
||||||
// add the v-wrapping
|
// add the v-wrapping
|
||||||
temp = (unsigned int)GetMapMode((*it).wrapModeHeight);
|
temp = (unsigned int)GetMapMode(texture.wrapModeHeight);
|
||||||
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_MAPPINGMODE_V(type,cur));
|
pcMat->AddProperty<int>((int*)&temp,1,AI_MATKEY_MAPPINGMODE_V(type,cur));
|
||||||
|
|
||||||
++cur;
|
++cur;
|
||||||
|
@ -343,16 +343,14 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat)
|
||||||
|
|
||||||
// Now we need to know which shader to use .. iterate through the shader list of
|
// Now we need to know which shader to use .. iterate through the shader list of
|
||||||
// the surface and search for a name which we know ...
|
// the surface and search for a name which we know ...
|
||||||
for (ShaderList::const_iterator it = surf.mShaders.begin(), end = surf.mShaders.end();it != end;++it) {
|
for (const auto &shader : surf.mShaders) {
|
||||||
//if (!(*it).enabled)continue;
|
if (shader.functionName == "LW_SuperCelShader" || shader.functionName == "AH_CelShader") {
|
||||||
|
|
||||||
if ((*it).functionName == "LW_SuperCelShader" || (*it).functionName == "AH_CelShader") {
|
|
||||||
DefaultLogger::get()->info("LWO2: Mapping LW_SuperCelShader/AH_CelShader to aiShadingMode_Toon");
|
DefaultLogger::get()->info("LWO2: Mapping LW_SuperCelShader/AH_CelShader to aiShadingMode_Toon");
|
||||||
|
|
||||||
m = aiShadingMode_Toon;
|
m = aiShadingMode_Toon;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ((*it).functionName == "LW_RealFresnel" || (*it).functionName == "LW_FastFresnel") {
|
else if (shader.functionName == "LW_RealFresnel" || shader.functionName == "LW_FastFresnel") {
|
||||||
DefaultLogger::get()->info("LWO2: Mapping LW_RealFresnel/LW_FastFresnel to aiShadingMode_Fresnel");
|
DefaultLogger::get()->info("LWO2: Mapping LW_RealFresnel/LW_FastFresnel to aiShadingMode_Fresnel");
|
||||||
|
|
||||||
m = aiShadingMode_Fresnel;
|
m = aiShadingMode_Fresnel;
|
||||||
|
@ -360,7 +358,7 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + (*it).functionName);
|
DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + shader.functionName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (surf.mMaximumSmoothAngle <= 0.0f)
|
if (surf.mMaximumSmoothAngle <= 0.0f)
|
||||||
|
@ -381,20 +379,20 @@ char LWOImporter::FindUVChannels(LWO::TextureList& list,
|
||||||
LWO::Layer& /*layer*/,LWO::UVChannel& uv, unsigned int next)
|
LWO::Layer& /*layer*/,LWO::UVChannel& uv, unsigned int next)
|
||||||
{
|
{
|
||||||
char ret = 0;
|
char ret = 0;
|
||||||
for (TextureList::iterator it = list.begin(), end = list.end();it != end;++it) {
|
for (auto &texture : list) {
|
||||||
|
|
||||||
// Ignore textures with non-UV mappings for the moment.
|
// Ignore textures with non-UV mappings for the moment.
|
||||||
if (!(*it).enabled || !(*it).bCanUse || (*it).mapMode != LWO::Texture::UV) {
|
if (!texture.enabled || !texture.bCanUse || texture.mapMode != LWO::Texture::UV) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*it).mUVChannelIndex == uv.name) {
|
if (texture.mUVChannelIndex == uv.name) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
// got it.
|
// got it.
|
||||||
if ((*it).mRealUVIndex == UINT_MAX || (*it).mRealUVIndex == next)
|
if (texture.mRealUVIndex == UINT_MAX || texture.mRealUVIndex == next)
|
||||||
{
|
{
|
||||||
(*it).mRealUVIndex = next;
|
texture.mRealUVIndex = next;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// channel mismatch. need to duplicate the material.
|
// channel mismatch. need to duplicate the material.
|
||||||
|
|
|
@ -193,13 +193,13 @@ bool MD5Parser::ParseSection(Section& out)
|
||||||
|
|
||||||
// skip all spaces ... handle EOL correctly
|
// skip all spaces ... handle EOL correctly
|
||||||
#define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \
|
#define AI_MD5_SKIP_SPACES() if(!SkipSpaces(&sz)) \
|
||||||
MD5Parser::ReportWarning("Unexpected end of line",(*eit).iLineNumber);
|
MD5Parser::ReportWarning("Unexpected end of line",elem.iLineNumber);
|
||||||
|
|
||||||
// read a triple float in brackets: (1.0 1.0 1.0)
|
// read a triple float in brackets: (1.0 1.0 1.0)
|
||||||
#define AI_MD5_READ_TRIPLE(vec) \
|
#define AI_MD5_READ_TRIPLE(vec) \
|
||||||
AI_MD5_SKIP_SPACES(); \
|
AI_MD5_SKIP_SPACES(); \
|
||||||
if ('(' != *sz++) \
|
if ('(' != *sz++) \
|
||||||
MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber); \
|
MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber); \
|
||||||
AI_MD5_SKIP_SPACES(); \
|
AI_MD5_SKIP_SPACES(); \
|
||||||
sz = fast_atoreal_move<float>(sz,(float&)vec.x); \
|
sz = fast_atoreal_move<float>(sz,(float&)vec.x); \
|
||||||
AI_MD5_SKIP_SPACES(); \
|
AI_MD5_SKIP_SPACES(); \
|
||||||
|
@ -208,7 +208,7 @@ bool MD5Parser::ParseSection(Section& out)
|
||||||
sz = fast_atoreal_move<float>(sz,(float&)vec.z); \
|
sz = fast_atoreal_move<float>(sz,(float&)vec.z); \
|
||||||
AI_MD5_SKIP_SPACES(); \
|
AI_MD5_SKIP_SPACES(); \
|
||||||
if (')' != *sz++) \
|
if (')' != *sz++) \
|
||||||
MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
|
MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
|
||||||
|
|
||||||
// parse a string, enclosed in quotation marks or not
|
// parse a string, enclosed in quotation marks or not
|
||||||
#define AI_MD5_PARSE_STRING(out) \
|
#define AI_MD5_PARSE_STRING(out) \
|
||||||
|
@ -220,7 +220,7 @@ bool MD5Parser::ParseSection(Section& out)
|
||||||
szStart++; \
|
szStart++; \
|
||||||
if ('\"' != *(szEnd-=1)) { \
|
if ('\"' != *(szEnd-=1)) { \
|
||||||
MD5Parser::ReportWarning("Expected closing quotation marks in string", \
|
MD5Parser::ReportWarning("Expected closing quotation marks in string", \
|
||||||
(*eit).iLineNumber); \
|
elem.iLineNumber); \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
@ -244,11 +244,11 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
}
|
}
|
||||||
else if ((*iter).mName == "joints") {
|
else if ((*iter).mName == "joints") {
|
||||||
// "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 )
|
// "origin" -1 ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000000 0.707107 )
|
||||||
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit){
|
for (const auto & elem : (*iter).mElements){
|
||||||
mJoints.push_back(BoneDesc());
|
mJoints.push_back(BoneDesc());
|
||||||
BoneDesc& desc = mJoints.back();
|
BoneDesc& desc = mJoints.back();
|
||||||
|
|
||||||
const char* sz = (*eit).szStart;
|
const char* sz = elem.szStart;
|
||||||
AI_MD5_PARSE_STRING(desc.mName);
|
AI_MD5_PARSE_STRING(desc.mName);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
|
||||||
|
@ -263,8 +263,8 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
mMeshes.push_back(MeshDesc());
|
mMeshes.push_back(MeshDesc());
|
||||||
MeshDesc& desc = mMeshes.back();
|
MeshDesc& desc = mMeshes.back();
|
||||||
|
|
||||||
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit){
|
for (const auto & elem : (*iter).mElements){
|
||||||
const char* sz = (*eit).szStart;
|
const char* sz = elem.szStart;
|
||||||
|
|
||||||
// shader attribute
|
// shader attribute
|
||||||
if (TokenMatch(sz,"shader",6)) {
|
if (TokenMatch(sz,"shader",6)) {
|
||||||
|
@ -297,14 +297,14 @@ MD5MeshParser::MD5MeshParser(SectionList& mSections)
|
||||||
|
|
||||||
VertexDesc& vert = desc.mVertices[idx];
|
VertexDesc& vert = desc.mVertices[idx];
|
||||||
if ('(' != *sz++)
|
if ('(' != *sz++)
|
||||||
MD5Parser::ReportWarning("Unexpected token: ( was expected",(*eit).iLineNumber);
|
MD5Parser::ReportWarning("Unexpected token: ( was expected",elem.iLineNumber);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.x);
|
sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.x);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.y);
|
sz = fast_atoreal_move<float>(sz,(float&)vert.mUV.y);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
if (')' != *sz++)
|
if (')' != *sz++)
|
||||||
MD5Parser::ReportWarning("Unexpected token: ) was expected",(*eit).iLineNumber);
|
MD5Parser::ReportWarning("Unexpected token: ) was expected",elem.iLineNumber);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
vert.mFirstWeight = ::strtoul10(sz,&sz);
|
vert.mFirstWeight = ::strtoul10(sz,&sz);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
@ -357,11 +357,11 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
|
||||||
for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) {
|
for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end();iter != iterEnd;++iter) {
|
||||||
if ((*iter).mName == "hierarchy") {
|
if ((*iter).mName == "hierarchy") {
|
||||||
// "sheath" 0 63 6
|
// "sheath" 0 63 6
|
||||||
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end();eit != eitEnd; ++eit) {
|
for (const auto & elem : (*iter).mElements) {
|
||||||
mAnimatedBones.push_back ( AnimBoneDesc () );
|
mAnimatedBones.push_back ( AnimBoneDesc () );
|
||||||
AnimBoneDesc& desc = mAnimatedBones.back();
|
AnimBoneDesc& desc = mAnimatedBones.back();
|
||||||
|
|
||||||
const char* sz = (*eit).szStart;
|
const char* sz = elem.szStart;
|
||||||
AI_MD5_PARSE_STRING(desc.mName);
|
AI_MD5_PARSE_STRING(desc.mName);
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
|
||||||
// flags (highest is 2^6-1)
|
// flags (highest is 2^6-1)
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
if(63 < (desc.iFlags = ::strtoul10(sz,&sz))){
|
if(63 < (desc.iFlags = ::strtoul10(sz,&sz))){
|
||||||
MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",(*eit).iLineNumber);
|
MD5Parser::ReportWarning("Invalid flag combination in hierarchy section",elem.iLineNumber);
|
||||||
}
|
}
|
||||||
AI_MD5_SKIP_SPACES();
|
AI_MD5_SKIP_SPACES();
|
||||||
|
|
||||||
|
@ -381,8 +381,8 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
|
||||||
}
|
}
|
||||||
else if((*iter).mName == "baseframe") {
|
else if((*iter).mName == "baseframe") {
|
||||||
// ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000242 0.707107 )
|
// ( -0.000000 0.016430 -0.006044 ) ( 0.707107 0.000242 0.707107 )
|
||||||
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit) {
|
for (const auto & elem : (*iter).mElements) {
|
||||||
const char* sz = (*eit).szStart;
|
const char* sz = elem.szStart;
|
||||||
|
|
||||||
mBaseFrames.push_back ( BaseFrameDesc () );
|
mBaseFrames.push_back ( BaseFrameDesc () );
|
||||||
BaseFrameDesc& desc = mBaseFrames.back();
|
BaseFrameDesc& desc = mBaseFrames.back();
|
||||||
|
@ -407,8 +407,8 @@ MD5AnimParser::MD5AnimParser(SectionList& mSections)
|
||||||
}
|
}
|
||||||
|
|
||||||
// now read all elements (continuous list of floats)
|
// now read all elements (continuous list of floats)
|
||||||
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){
|
for (const auto & elem : (*iter).mElements){
|
||||||
const char* sz = (*eit).szStart;
|
const char* sz = elem.szStart;
|
||||||
while (SkipSpacesAndLineEnd(&sz)) {
|
while (SkipSpacesAndLineEnd(&sz)) {
|
||||||
float f;sz = fast_atoreal_move<float>(sz,f);
|
float f;sz = fast_atoreal_move<float>(sz,f);
|
||||||
desc.mValues.push_back(f);
|
desc.mValues.push_back(f);
|
||||||
|
@ -455,13 +455,13 @@ MD5CameraParser::MD5CameraParser(SectionList& mSections)
|
||||||
cuts.reserve(strtoul10((*iter).mGlobalValue.c_str()));
|
cuts.reserve(strtoul10((*iter).mGlobalValue.c_str()));
|
||||||
}
|
}
|
||||||
else if ((*iter).mName == "cuts") {
|
else if ((*iter).mName == "cuts") {
|
||||||
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){
|
for (const auto & elem : (*iter).mElements){
|
||||||
cuts.push_back(strtoul10((*eit).szStart)+1);
|
cuts.push_back(strtoul10(elem.szStart)+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((*iter).mName == "camera") {
|
else if ((*iter).mName == "camera") {
|
||||||
for (ElementList::const_iterator eit = (*iter).mElements.begin(), eitEnd = (*iter).mElements.end(); eit != eitEnd; ++eit){
|
for (const auto & elem : (*iter).mElements){
|
||||||
const char* sz = (*eit).szStart;
|
const char* sz = elem.szStart;
|
||||||
|
|
||||||
frames.push_back(CameraAnimFrameDesc());
|
frames.push_back(CameraAnimFrameDesc());
|
||||||
CameraAnimFrameDesc& cur = frames.back();
|
CameraAnimFrameDesc& cur = frames.back();
|
||||||
|
|
|
@ -673,12 +673,11 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
if ('t' == line[0])
|
if ('t' == line[0])
|
||||||
{
|
{
|
||||||
currentMeshWithUVCoords = NULL;
|
currentMeshWithUVCoords = NULL;
|
||||||
for (std::vector<MeshInfo>::iterator it = meshesWithUVCoords.begin(), end = meshesWithUVCoords.end();
|
for (auto &mesh : meshesWithUVCoords)
|
||||||
it != end;++it)
|
|
||||||
{
|
{
|
||||||
if ((*it).shader == s)
|
if (mesh.shader == s)
|
||||||
{
|
{
|
||||||
currentMeshWithUVCoords = &(*it);
|
currentMeshWithUVCoords = &mesh;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -695,12 +694,11 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
else if ('p' == line[1])
|
else if ('p' == line[1])
|
||||||
{
|
{
|
||||||
currentMeshWithNormals = NULL;
|
currentMeshWithNormals = NULL;
|
||||||
for (std::vector<MeshInfo>::iterator it = meshesWithNormals.begin(), end = meshesWithNormals.end();
|
for (auto &mesh : meshesWithNormals)
|
||||||
it != end;++it)
|
|
||||||
{
|
{
|
||||||
if ((*it).shader == s)
|
if (mesh.shader == s)
|
||||||
{
|
{
|
||||||
currentMeshWithNormals = &(*it);
|
currentMeshWithNormals = &mesh;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -717,12 +715,11 @@ void NFFImporter::InternReadFile( const std::string& pFile,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentMesh = NULL;
|
currentMesh = NULL;
|
||||||
for (std::vector<MeshInfo>::iterator it = meshes.begin(), end = meshes.end();
|
for (auto &mesh : meshes)
|
||||||
it != end;++it)
|
|
||||||
{
|
{
|
||||||
if ((*it).shader == s)
|
if (mesh.shader == s)
|
||||||
{
|
{
|
||||||
currentMesh = &(*it);
|
currentMesh = &mesh;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,10 +501,8 @@ void OgreBinarySerializer::NormalizeBoneWeights(VertexData *vertexData) const
|
||||||
Some exporters wont care if the sum of all bone weights
|
Some exporters wont care if the sum of all bone weights
|
||||||
for a single vertex equals 1 or not, so validate here. */
|
for a single vertex equals 1 or not, so validate here. */
|
||||||
const float epsilon = 0.05f;
|
const float epsilon = 0.05f;
|
||||||
for(std::set<uint32_t>::const_iterator iter=influencedVertices.begin(), end=influencedVertices.end(); iter != end; ++iter)
|
for (const uint32_t vertexIndex : influencedVertices)
|
||||||
{
|
{
|
||||||
const uint32_t vertexIndex = (*iter);
|
|
||||||
|
|
||||||
float sum = 0.0f;
|
float sum = 0.0f;
|
||||||
for (VertexBoneAssignmentList::const_iterator baIter=vertexData->boneAssignments.begin(), baEnd=vertexData->boneAssignments.end(); baIter != baEnd; ++baIter)
|
for (VertexBoneAssignmentList::const_iterator baIter=vertexData->boneAssignments.begin(), baEnd=vertexData->boneAssignments.end(); baIter != baEnd; ++baIter)
|
||||||
{
|
{
|
||||||
|
@ -513,10 +511,10 @@ void OgreBinarySerializer::NormalizeBoneWeights(VertexData *vertexData) const
|
||||||
}
|
}
|
||||||
if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon)))
|
if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon)))
|
||||||
{
|
{
|
||||||
for (VertexBoneAssignmentList::iterator baIter=vertexData->boneAssignments.begin(), baEnd=vertexData->boneAssignments.end(); baIter != baEnd; ++baIter)
|
for (auto &boneAssign : vertexData->boneAssignments)
|
||||||
{
|
{
|
||||||
if (baIter->vertexIndex == vertexIndex)
|
if (boneAssign.vertexIndex == vertexIndex)
|
||||||
baIter->weight /= sum;
|
boneAssign.weight /= sum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,12 +258,11 @@ void IVertexData::AddVertexMapping(uint32_t oldIndex, uint32_t newIndex)
|
||||||
|
|
||||||
void IVertexData::BoneAssignmentsForVertex(uint32_t currentIndex, uint32_t newIndex, VertexBoneAssignmentList &dest) const
|
void IVertexData::BoneAssignmentsForVertex(uint32_t currentIndex, uint32_t newIndex, VertexBoneAssignmentList &dest) const
|
||||||
{
|
{
|
||||||
for (VertexBoneAssignmentList::const_iterator iter=boneAssignments.begin(), end=boneAssignments.end();
|
for (const auto &boneAssign : boneAssignments)
|
||||||
iter!=end; ++iter)
|
|
||||||
{
|
{
|
||||||
if (iter->vertexIndex == currentIndex)
|
if (boneAssign.vertexIndex == currentIndex)
|
||||||
{
|
{
|
||||||
VertexBoneAssignment a = (*iter);
|
VertexBoneAssignment a = boneAssign;
|
||||||
a.vertexIndex = newIndex;
|
a.vertexIndex = newIndex;
|
||||||
dest.push_back(a);
|
dest.push_back(a);
|
||||||
}
|
}
|
||||||
|
@ -289,10 +288,9 @@ AssimpVertexBoneWeightList IVertexData::AssimpBoneWeights(size_t vertices)
|
||||||
std::set<uint16_t> IVertexData::ReferencedBonesByWeights() const
|
std::set<uint16_t> IVertexData::ReferencedBonesByWeights() const
|
||||||
{
|
{
|
||||||
std::set<uint16_t> referenced;
|
std::set<uint16_t> referenced;
|
||||||
for (VertexBoneAssignmentList::const_iterator iter=boneAssignments.begin(), end=boneAssignments.end();
|
for (const auto &boneAssign : boneAssignments)
|
||||||
iter!=end; ++iter)
|
|
||||||
{
|
{
|
||||||
referenced.insert(iter->boneIndex);
|
referenced.insert(boneAssign.boneIndex);
|
||||||
}
|
}
|
||||||
return referenced;
|
return referenced;
|
||||||
}
|
}
|
||||||
|
@ -318,10 +316,10 @@ void VertexData::Reset()
|
||||||
uint32_t VertexData::VertexSize(uint16_t source) const
|
uint32_t VertexData::VertexSize(uint16_t source) const
|
||||||
{
|
{
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
for(VertexElementList::const_iterator iter=vertexElements.begin(), end=vertexElements.end(); iter != end; ++iter)
|
for(const auto &element : vertexElements)
|
||||||
{
|
{
|
||||||
if (iter->source == source)
|
if (element.source == source)
|
||||||
size += iter->Size();
|
size += element.Size();
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -335,9 +333,8 @@ MemoryStream *VertexData::VertexBuffer(uint16_t source)
|
||||||
|
|
||||||
VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, uint16_t index)
|
VertexElement *VertexData::GetVertexElement(VertexElement::Semantic semantic, uint16_t index)
|
||||||
{
|
{
|
||||||
for(VertexElementList::iterator iter=vertexElements.begin(), end=vertexElements.end(); iter != end; ++iter)
|
for(auto & element : vertexElements)
|
||||||
{
|
{
|
||||||
VertexElement &element = (*iter);
|
|
||||||
if (element.semantic == semantic && element.index == index)
|
if (element.semantic == semantic && element.index == index)
|
||||||
return &element;
|
return &element;
|
||||||
}
|
}
|
||||||
|
@ -427,16 +424,16 @@ void Mesh::Reset()
|
||||||
OGRE_SAFE_DELETE(skeleton)
|
OGRE_SAFE_DELETE(skeleton)
|
||||||
OGRE_SAFE_DELETE(sharedVertexData)
|
OGRE_SAFE_DELETE(sharedVertexData)
|
||||||
|
|
||||||
for(size_t i=0, len=subMeshes.size(); i<len; ++i) {
|
for(auto &mesh : subMeshes) {
|
||||||
OGRE_SAFE_DELETE(subMeshes[i])
|
OGRE_SAFE_DELETE(mesh)
|
||||||
}
|
}
|
||||||
subMeshes.clear();
|
subMeshes.clear();
|
||||||
for(size_t i=0, len=animations.size(); i<len; ++i) {
|
for(auto &anim : animations) {
|
||||||
OGRE_SAFE_DELETE(animations[i])
|
OGRE_SAFE_DELETE(anim)
|
||||||
}
|
}
|
||||||
animations.clear();
|
animations.clear();
|
||||||
for(size_t i=0, len=poses.size(); i<len; ++i) {
|
for(auto &pose : poses) {
|
||||||
OGRE_SAFE_DELETE(poses[i])
|
OGRE_SAFE_DELETE(pose)
|
||||||
}
|
}
|
||||||
poses.clear();
|
poses.clear();
|
||||||
}
|
}
|
||||||
|
@ -739,8 +736,8 @@ void MeshXml::Reset()
|
||||||
OGRE_SAFE_DELETE(skeleton)
|
OGRE_SAFE_DELETE(skeleton)
|
||||||
OGRE_SAFE_DELETE(sharedVertexData)
|
OGRE_SAFE_DELETE(sharedVertexData)
|
||||||
|
|
||||||
for(size_t i=0, len=subMeshes.size(); i<len; ++i) {
|
for(auto &mesh : subMeshes) {
|
||||||
OGRE_SAFE_DELETE(subMeshes[i])
|
OGRE_SAFE_DELETE(mesh)
|
||||||
}
|
}
|
||||||
subMeshes.clear();
|
subMeshes.clear();
|
||||||
}
|
}
|
||||||
|
@ -988,12 +985,12 @@ Skeleton::~Skeleton()
|
||||||
|
|
||||||
void Skeleton::Reset()
|
void Skeleton::Reset()
|
||||||
{
|
{
|
||||||
for(size_t i=0, len=bones.size(); i<len; ++i) {
|
for(auto &bone : bones) {
|
||||||
OGRE_SAFE_DELETE(bones[i])
|
OGRE_SAFE_DELETE(bone)
|
||||||
}
|
}
|
||||||
bones.clear();
|
bones.clear();
|
||||||
for(size_t i=0, len=animations.size(); i<len; ++i) {
|
for(auto &anim : animations) {
|
||||||
OGRE_SAFE_DELETE(animations[i])
|
OGRE_SAFE_DELETE(anim)
|
||||||
}
|
}
|
||||||
animations.clear();
|
animations.clear();
|
||||||
}
|
}
|
||||||
|
@ -1082,11 +1079,11 @@ void Bone::CalculateWorldMatrixAndDefaultPose(Skeleton *skeleton)
|
||||||
defaultPose = aiMatrix4x4(scale, rotation, position);
|
defaultPose = aiMatrix4x4(scale, rotation, position);
|
||||||
|
|
||||||
// Recursively for all children now that the parent matrix has been calculated.
|
// Recursively for all children now that the parent matrix has been calculated.
|
||||||
for (size_t i=0, len=children.size(); i<len; ++i)
|
for (auto boneId : children)
|
||||||
{
|
{
|
||||||
Bone *child = skeleton->BoneById(children[i]);
|
Bone *child = skeleton->BoneById(boneId);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
throw DeadlyImportError(Formatter::format() << "CalculateWorldMatrixAndDefaultPose: Failed to find child bone " << children[i] << " for parent " << id << " " << name);
|
throw DeadlyImportError(Formatter::format() << "CalculateWorldMatrixAndDefaultPose: Failed to find child bone " << boneId << " for parent " << id << " " << name);
|
||||||
}
|
}
|
||||||
child->CalculateWorldMatrixAndDefaultPose(skeleton);
|
child->CalculateWorldMatrixAndDefaultPose(skeleton);
|
||||||
}
|
}
|
||||||
|
|
|
@ -453,7 +453,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest)
|
||||||
}
|
}
|
||||||
else if (uvs > 0 && m_currentNodeName == nnTexCoord)
|
else if (uvs > 0 && m_currentNodeName == nnTexCoord)
|
||||||
{
|
{
|
||||||
for(size_t i=0, len=dest->uvs.size(); i<len; ++i)
|
for(auto &uvs : dest->uvs)
|
||||||
{
|
{
|
||||||
if (m_currentNodeName != nnTexCoord) {
|
if (m_currentNodeName != nnTexCoord) {
|
||||||
throw DeadlyImportError("Vertex buffer declared more UVs than can be found in a vertex");
|
throw DeadlyImportError("Vertex buffer declared more UVs than can be found in a vertex");
|
||||||
|
@ -462,7 +462,7 @@ void OgreXmlSerializer::ReadGeometryVertexBuffer(VertexDataXml *dest)
|
||||||
aiVector3D uv;
|
aiVector3D uv;
|
||||||
uv.x = ReadAttribute<float>("u");
|
uv.x = ReadAttribute<float>("u");
|
||||||
uv.y = (ReadAttribute<float>("v") * -1) + 1; // Flip UV from Ogre to Assimp form
|
uv.y = (ReadAttribute<float>("v") * -1) + 1; // Flip UV from Ogre to Assimp form
|
||||||
dest->uvs[i].push_back(uv);
|
uvs.push_back(uv);
|
||||||
|
|
||||||
NextNode();
|
NextNode();
|
||||||
}
|
}
|
||||||
|
@ -657,10 +657,8 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest)
|
||||||
Some exporters wont care if the sum of all bone weights
|
Some exporters wont care if the sum of all bone weights
|
||||||
for a single vertex equals 1 or not, so validate here. */
|
for a single vertex equals 1 or not, so validate here. */
|
||||||
const float epsilon = 0.05f;
|
const float epsilon = 0.05f;
|
||||||
for(std::set<uint32_t>::const_iterator iter=influencedVertices.begin(), end=influencedVertices.end(); iter != end; ++iter)
|
for (const uint32_t vertexIndex : influencedVertices)
|
||||||
{
|
{
|
||||||
const uint32_t vertexIndex = (*iter);
|
|
||||||
|
|
||||||
float sum = 0.0f;
|
float sum = 0.0f;
|
||||||
for (VertexBoneAssignmentList::const_iterator baIter=dest->boneAssignments.begin(), baEnd=dest->boneAssignments.end(); baIter != baEnd; ++baIter)
|
for (VertexBoneAssignmentList::const_iterator baIter=dest->boneAssignments.begin(), baEnd=dest->boneAssignments.end(); baIter != baEnd; ++baIter)
|
||||||
{
|
{
|
||||||
|
@ -669,10 +667,10 @@ void OgreXmlSerializer::ReadBoneAssignments(VertexDataXml *dest)
|
||||||
}
|
}
|
||||||
if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon)))
|
if ((sum < (1.0f - epsilon)) || (sum > (1.0f + epsilon)))
|
||||||
{
|
{
|
||||||
for (VertexBoneAssignmentList::iterator baIter=dest->boneAssignments.begin(), baEnd=dest->boneAssignments.end(); baIter != baEnd; ++baIter)
|
for (auto &boneAssign : dest->boneAssignments)
|
||||||
{
|
{
|
||||||
if (baIter->vertexIndex == vertexIndex)
|
if (boneAssign.vertexIndex == vertexIndex)
|
||||||
baIter->weight /= sum;
|
boneAssign.weight /= sum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,8 +236,8 @@ OpenGEXImporter::VertexContainer::~VertexContainer() {
|
||||||
delete[] m_vertices;
|
delete[] m_vertices;
|
||||||
delete[] m_normals;
|
delete[] m_normals;
|
||||||
|
|
||||||
for( size_t i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++ ) {
|
for(auto &texcoords : m_textureCoords) {
|
||||||
delete [] m_textureCoords[ i ];
|
delete [] texcoords;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,11 +131,11 @@ static void normalizePathName( const std::string &rPath, std::string &rNormalize
|
||||||
static const unsigned int numDelimiters = 2;
|
static const unsigned int numDelimiters = 2;
|
||||||
const char delimiters[ numDelimiters ] = { '/', '\\' };
|
const char delimiters[ numDelimiters ] = { '/', '\\' };
|
||||||
rNormalizedPath = rPath;
|
rNormalizedPath = rPath;
|
||||||
for ( unsigned int i=0; i<numDelimiters; i++ )
|
for (const char delimiter : delimiters)
|
||||||
{
|
{
|
||||||
for ( size_t j=0; j<rNormalizedPath.size(); j++ )
|
for ( size_t j=0; j<rNormalizedPath.size(); j++ )
|
||||||
{
|
{
|
||||||
if ( rNormalizedPath[j] == delimiters[ i ] )
|
if ( rNormalizedPath[j] == delimiter )
|
||||||
{
|
{
|
||||||
rNormalizedPath[ j ] = sep[ 0 ];
|
rNormalizedPath[ j ] = sep[ 0 ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,8 +195,8 @@ Q3BSPZipArchive::Q3BSPZipArchive(IOSystem* pIOHandler, const std::string& rFile)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor.
|
// Destructor.
|
||||||
Q3BSPZipArchive::~Q3BSPZipArchive() {
|
Q3BSPZipArchive::~Q3BSPZipArchive() {
|
||||||
for( std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it ) {
|
for(auto &file : m_ArchiveMap) {
|
||||||
delete it->second;
|
delete file.second;
|
||||||
}
|
}
|
||||||
m_ArchiveMap.clear();
|
m_ArchiveMap.clear();
|
||||||
|
|
||||||
|
@ -269,8 +269,8 @@ void Q3BSPZipArchive::Close(IOStream *pFile) {
|
||||||
void Q3BSPZipArchive::getFileList(std::vector<std::string> &rFileList) {
|
void Q3BSPZipArchive::getFileList(std::vector<std::string> &rFileList) {
|
||||||
rFileList.clear();
|
rFileList.clear();
|
||||||
|
|
||||||
for(std::map<std::string, ZipFile*>::iterator it(m_ArchiveMap.begin()), end(m_ArchiveMap.end()); it != end; ++it) {
|
for(auto &file : m_ArchiveMap) {
|
||||||
rFileList.push_back(it->first);
|
rFileList.push_back(file.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,12 +183,11 @@ void RAWImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
// search in the list of meshes whether we have one with this texture
|
// search in the list of meshes whether we have one with this texture
|
||||||
for (std::vector< MeshInformation >::iterator it = (*curGroup).meshes.begin(),
|
for (auto &mesh : (*curGroup).meshes)
|
||||||
end = (*curGroup).meshes.end(); it != end; ++it)
|
|
||||||
{
|
{
|
||||||
if (length == (*it).name.length() && (length ? !::strcmp(sz,(*it).name.c_str()) : true))
|
if (length == mesh.name.length() && (length ? !::strcmp(sz, mesh.name.c_str()) : true))
|
||||||
{
|
{
|
||||||
output = &(*it);
|
output = &mesh;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,13 +222,12 @@ void RAWImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// count the number of valid groups
|
// count the number of valid groups
|
||||||
// (meshes can't be empty)
|
// (meshes can't be empty)
|
||||||
for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end();
|
for (auto & outGroup : outGroups)
|
||||||
it != end;++it)
|
|
||||||
{
|
{
|
||||||
if (!(*it).meshes.empty())
|
if (!outGroup.meshes.empty())
|
||||||
{
|
{
|
||||||
++pScene->mRootNode->mNumChildren;
|
++pScene->mRootNode->mNumChildren;
|
||||||
pScene->mNumMeshes += (unsigned int)(*it).meshes.size();
|
pScene->mNumMeshes += (unsigned int) outGroup.meshes.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,10 +249,9 @@ void RAWImporter::InternReadFile( const std::string& pFile,
|
||||||
aiMaterial** mats = pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
aiMaterial** mats = pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
|
||||||
|
|
||||||
unsigned int meshIdx = 0;
|
unsigned int meshIdx = 0;
|
||||||
for (std::vector< GroupInformation >::iterator it = outGroups.begin(), end = outGroups.end();
|
for (auto & outGroup : outGroups)
|
||||||
it != end;++it)
|
|
||||||
{
|
{
|
||||||
if ((*it).meshes.empty())continue;
|
if (outGroup.meshes.empty())continue;
|
||||||
|
|
||||||
aiNode* node;
|
aiNode* node;
|
||||||
if (pScene->mRootNode->mNumChildren)
|
if (pScene->mRootNode->mNumChildren)
|
||||||
|
@ -263,13 +260,13 @@ void RAWImporter::InternReadFile( const std::string& pFile,
|
||||||
node->mParent = pScene->mRootNode;
|
node->mParent = pScene->mRootNode;
|
||||||
}
|
}
|
||||||
else node = *cc;++cc;
|
else node = *cc;++cc;
|
||||||
node->mName.Set((*it).name);
|
node->mName.Set(outGroup.name);
|
||||||
|
|
||||||
// add all meshes
|
// add all meshes
|
||||||
node->mNumMeshes = (unsigned int)(*it).meshes.size();
|
node->mNumMeshes = (unsigned int) outGroup.meshes.size();
|
||||||
unsigned int* pi = node->mMeshes = new unsigned int[ node->mNumMeshes ];
|
unsigned int* pi = node->mMeshes = new unsigned int[ node->mNumMeshes ];
|
||||||
for (std::vector< MeshInformation >::iterator it2 = (*it).meshes.begin(),
|
for (std::vector< MeshInformation >::iterator it2 = outGroup.meshes.begin(),
|
||||||
end2 = (*it).meshes.end(); it2 != end2; ++it2)
|
end2 = outGroup.meshes.end(); it2 != end2; ++it2)
|
||||||
{
|
{
|
||||||
ai_assert(!(*it2).vertices.empty());
|
ai_assert(!(*it2).vertices.empty());
|
||||||
|
|
||||||
|
|
|
@ -459,11 +459,9 @@ void SplitLargeMeshesProcess_Vertex::SplitMesh(
|
||||||
if (iBase)
|
if (iBase)
|
||||||
{
|
{
|
||||||
// we can't use memset here we unsigned int needn' be 32 bits
|
// we can't use memset here we unsigned int needn' be 32 bits
|
||||||
for (std::vector<unsigned int>::iterator
|
for (auto &elem : avWasCopied)
|
||||||
iter = avWasCopied.begin(),end = avWasCopied.end();
|
|
||||||
iter != end;++iter)
|
|
||||||
{
|
{
|
||||||
(*iter) = 0xffffffff;
|
elem = 0xffffffff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,9 +171,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// collect triangles
|
// collect triangles
|
||||||
std::vector<Unreal::Triangle> triangles(numTris);
|
std::vector<Unreal::Triangle> triangles(numTris);
|
||||||
for (std::vector<Unreal::Triangle>::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) {
|
for (auto & tri : triangles) {
|
||||||
Unreal::Triangle& tri = *it;
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 3;++i) {
|
for (unsigned int i = 0; i < 3;++i) {
|
||||||
|
|
||||||
tri.mVertex[i] = d_reader.GetI2();
|
tri.mVertex[i] = d_reader.GetI2();
|
||||||
|
@ -222,9 +220,9 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// collect vertices
|
// collect vertices
|
||||||
std::vector<aiVector3D> vertices(numVert);
|
std::vector<aiVector3D> vertices(numVert);
|
||||||
for (std::vector<aiVector3D>::iterator it = vertices.begin(), end = vertices.end(); it != end; ++it) {
|
for (auto &vertex : vertices) {
|
||||||
int32_t val = a_reader.GetI4();
|
int32_t val = a_reader.GetI4();
|
||||||
Unreal::DecompressVertex(*it,val);
|
Unreal::DecompressVertex(vertex ,val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// list of textures.
|
// list of textures.
|
||||||
|
@ -330,8 +328,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
materials.reserve(textures.size()*2+5);
|
materials.reserve(textures.size()*2+5);
|
||||||
|
|
||||||
// find out how many output meshes and materials we'll have and build material indices
|
// find out how many output meshes and materials we'll have and build material indices
|
||||||
for (std::vector<Unreal::Triangle>::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) {
|
for (Unreal::Triangle &tri : triangles) {
|
||||||
Unreal::Triangle& tri = *it;
|
|
||||||
Unreal::TempMat mat(tri);
|
Unreal::TempMat mat(tri);
|
||||||
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
|
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
|
||||||
if (nt == materials.end()) {
|
if (nt == materials.end()) {
|
||||||
|
@ -418,8 +415,7 @@ void UnrealImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill them.
|
// fill them.
|
||||||
for (std::vector<Unreal::Triangle>::iterator it = triangles.begin(), end = triangles.end();it != end; ++it) {
|
for (const Unreal::Triangle &tri : triangles) {
|
||||||
Unreal::Triangle& tri = *it;
|
|
||||||
Unreal::TempMat mat(tri);
|
Unreal::TempMat mat(tri);
|
||||||
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
|
std::vector<Unreal::TempMat>::iterator nt = std::find(materials.begin(),materials.end(),mat);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ setup(name='pyassimp',
|
||||||
version='0.1',
|
version='0.1',
|
||||||
license='ISC',
|
license='ISC',
|
||||||
description='Python bindings for the Open Asset Import Library (ASSIMP)',
|
description='Python bindings for the Open Asset Import Library (ASSIMP)',
|
||||||
url='http://assimp.sourceforge.net/',
|
url='https://github.com/assimp/assimp',
|
||||||
packages=['pyassimp'],
|
packages=['pyassimp'],
|
||||||
data_files=[('share/pyassimp', ['README.md']),
|
data_files=[('share/pyassimp', ['README.md']),
|
||||||
('share/examples/pyassimp', ['scripts/' + f for f in os.listdir('scripts/')])]
|
('share/examples/pyassimp', ['scripts/' + f for f in os.listdir('scripts/')])]
|
||||||
|
|
Loading…
Reference in New Issue