* Revert "Refactoring: use using types (#6266)"
This commit is contained in:
@@ -321,7 +321,7 @@ void Discreet3DSImporter::ConvertMaterial(Material &oldMat, aiMaterial &mat) {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Split meshes by their materials and generate output aiMesh'es
|
||||
void Discreet3DSImporter::ConvertMeshes(aiScene *pcOut) {
|
||||
MeshArray avOutMeshes;
|
||||
std::vector<aiMesh *> avOutMeshes;
|
||||
avOutMeshes.reserve(mScene->mMeshes.size() * 2);
|
||||
|
||||
unsigned int iFaceCnt = 0, num = 0;
|
||||
|
||||
@@ -147,7 +147,7 @@ struct Component {
|
||||
|
||||
class Object final : public Resource {
|
||||
public:
|
||||
MeshArray mMeshes;
|
||||
std::vector<aiMesh *> mMeshes;
|
||||
std::vector<unsigned int> mMeshIndex;
|
||||
std::vector<Component> mComponents;
|
||||
std::string mName;
|
||||
|
||||
@@ -418,7 +418,7 @@ void AC3DImporter::ConvertMaterial(const Object &object,
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Converts the loaded data to the internal verbose representation
|
||||
aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
||||
MeshArray &meshes,
|
||||
std::vector<aiMesh *> &meshes,
|
||||
std::vector<aiMaterial *> &outMaterials,
|
||||
const std::vector<Material> &materials,
|
||||
aiNode *parent) {
|
||||
@@ -710,7 +710,7 @@ aiNode *AC3DImporter::ConvertObjectSection(Object &object,
|
||||
std::unique_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE));
|
||||
ASSIMP_LOG_INFO("AC3D: Evaluating subdivision surface: ", object.name);
|
||||
|
||||
MeshArray cpy(meshes.size() - oldm, nullptr);
|
||||
std::vector<aiMesh *> cpy(meshes.size() - oldm, nullptr);
|
||||
div->Subdivide(&meshes[oldm], cpy.size(), &cpy.front(), object.subDiv, true);
|
||||
std::copy(cpy.begin(), cpy.end(), meshes.begin() + oldm);
|
||||
|
||||
@@ -846,7 +846,7 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
|
||||
}
|
||||
|
||||
mNumMeshes += (mNumMeshes >> 2u) + 1;
|
||||
MeshArray meshes;
|
||||
std::vector<aiMesh *> meshes;
|
||||
meshes.reserve(mNumMeshes);
|
||||
|
||||
std::vector<aiMaterial *> omaterials;
|
||||
|
||||
@@ -226,7 +226,7 @@ private:
|
||||
* @param materials Material list
|
||||
* @param Scenegraph node for the object */
|
||||
aiNode *ConvertObjectSection(Object &object,
|
||||
MeshArray &meshes,
|
||||
std::vector<aiMesh *> &meshes,
|
||||
std::vector<aiMaterial *> &outMaterials,
|
||||
const std::vector<Material> &materials,
|
||||
aiNode *parent = nullptr);
|
||||
|
||||
@@ -99,6 +99,8 @@ namespace Assimp {
|
||||
///
|
||||
class AMFImporter final : public BaseImporter {
|
||||
using AMFMetaDataArray = std::vector<AMFMetadata *>;
|
||||
using MeshArray = std::vector<aiMesh *>;
|
||||
using NodeArray = std::vector<aiNode *>;
|
||||
|
||||
public:
|
||||
struct SPP_Material;
|
||||
|
||||
@@ -162,7 +162,7 @@ void ASEImporter::InternReadFile(const std::string &pFile,
|
||||
|
||||
// process all meshes
|
||||
bool tookNormals = false;
|
||||
MeshArray avOutMeshes;
|
||||
std::vector<aiMesh *> avOutMeshes;
|
||||
avOutMeshes.reserve(mParser->m_vMeshes.size() * 2);
|
||||
for (std::vector<ASE::Mesh>::iterator i = mParser->m_vMeshes.begin(); i != mParser->m_vMeshes.end(); ++i) {
|
||||
if ((*i).bSkip) {
|
||||
@@ -187,7 +187,7 @@ void ASEImporter::InternReadFile(const std::string &pFile,
|
||||
// Now build the output mesh list. Remove dummies
|
||||
pScene->mNumMeshes = (unsigned int)avOutMeshes.size();
|
||||
aiMesh **pp = pScene->mMeshes = new aiMesh *[pScene->mNumMeshes];
|
||||
for (MeshArray::const_iterator i = avOutMeshes.begin(); i != avOutMeshes.end(); ++i) {
|
||||
for (std::vector<aiMesh *>::const_iterator i = avOutMeshes.begin(); i != avOutMeshes.end(); ++i) {
|
||||
if (!(*i)->mNumFaces) {
|
||||
continue;
|
||||
}
|
||||
@@ -902,7 +902,7 @@ void ASEImporter::ConvertMaterial(ASE::Material &mat) {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Build output meshes
|
||||
void ASEImporter::ConvertMeshes(ASE::Mesh &mesh, MeshArray &avOutMeshes) {
|
||||
void ASEImporter::ConvertMeshes(ASE::Mesh &mesh, std::vector<aiMesh *> &avOutMeshes) {
|
||||
// validate the material index of the mesh
|
||||
if (mesh.iMaterialIndex >= mParser->m_vMaterials.size()) {
|
||||
mesh.iMaterialIndex = (unsigned int)mParser->m_vMaterials.size() - 1;
|
||||
|
||||
@@ -961,7 +961,7 @@ void BlenderImporter::ConvertMesh(const Scene & /*in*/, const Object * /*obj*/,
|
||||
if (mesh->totface > static_cast<int>(mesh->mtface.size())) {
|
||||
ThrowException("Number of UV faces is larger than the corresponding UV face array (#1)");
|
||||
}
|
||||
for (MeshArray::iterator it = temp->begin() + old; it != temp->end(); ++it) {
|
||||
for (std::vector<aiMesh *>::iterator it = temp->begin() + old; it != temp->end(); ++it) {
|
||||
ai_assert(0 != (*it)->mNumVertices);
|
||||
ai_assert(0 != (*it)->mNumFaces);
|
||||
const auto itMatTexUvMapping = matTexUvMappings.find((*it)->mMaterialIndex);
|
||||
@@ -1030,7 +1030,7 @@ void BlenderImporter::ConvertMesh(const Scene & /*in*/, const Object * /*obj*/,
|
||||
if (mesh->totface > static_cast<int>(mesh->tface.size())) {
|
||||
ThrowException("Number of faces is larger than the corresponding UV face array (#2)");
|
||||
}
|
||||
for (MeshArray::iterator it = temp->begin() + old; it != temp->end(); ++it) {
|
||||
for (std::vector<aiMesh *>::iterator it = temp->begin() + old; it != temp->end(); ++it) {
|
||||
ai_assert(0 != (*it)->mNumVertices);
|
||||
ai_assert(0 != (*it)->mNumFaces);
|
||||
|
||||
@@ -1057,7 +1057,7 @@ void BlenderImporter::ConvertMesh(const Scene & /*in*/, const Object * /*obj*/,
|
||||
if (mesh->totface > static_cast<int>((mesh->mcol.size() / 4))) {
|
||||
ThrowException("Number of faces is larger than the corresponding color face array");
|
||||
}
|
||||
for (MeshArray::iterator it = temp->begin() + old; it != temp->end(); ++it) {
|
||||
for (std::vector<aiMesh *>::iterator it = temp->begin() + old; it != temp->end(); ++it) {
|
||||
ai_assert(0 != (*it)->mNumVertices);
|
||||
ai_assert(0 != (*it)->mNumFaces);
|
||||
|
||||
|
||||
@@ -166,10 +166,10 @@ void C4DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||
// copy meshes over
|
||||
pScene->mNumMeshes = static_cast<unsigned int>(meshes.size());
|
||||
pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]();
|
||||
std::copy(mMeshes.begin(), mMeshes.end(), pScene->mMeshes);
|
||||
std::copy(meshes.begin(), meshes.end(), pScene->mMeshes);
|
||||
|
||||
// copy materials over, adding a default material if necessary
|
||||
unsigned int mat_count = static_cast<unsigned int>(mMaterials.size());
|
||||
unsigned int mat_count = static_cast<unsigned int>(materials.size());
|
||||
for(aiMesh* mesh : meshes) {
|
||||
ai_assert(mesh->mMaterialIndex <= mat_count);
|
||||
if(mesh->mMaterialIndex >= mat_count) {
|
||||
@@ -179,14 +179,14 @@ void C4DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
|
||||
const aiString name(AI_DEFAULT_MATERIAL_NAME);
|
||||
def_material->AddProperty(&name, AI_MATKEY_NAME);
|
||||
|
||||
mMaterials.push_back(def_material.release());
|
||||
materials.push_back(def_material.release());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pScene->mNumMaterials = static_cast<unsigned int>(materials.size());
|
||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]();
|
||||
std::copy(mMaterials.begin(), mMaterials.end(), pScene->mMaterials);
|
||||
std::copy(materials.begin(), materials.end(), pScene->mMaterials);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -251,8 +251,8 @@ void C4DImporter::ReadMaterials(BaseMaterial* mat) {
|
||||
while (mat) {
|
||||
if (mat->GetType() == Mmaterial) {
|
||||
aiMaterial* out = new aiMaterial();
|
||||
mMaterialMapping[mat] = static_cast<unsigned int>(mMaterials.size());
|
||||
mMaterials.push_back(out);
|
||||
material_mapping[mat] = static_cast<unsigned int>(materials.size());
|
||||
materials.push_back(out);
|
||||
|
||||
auto const ai_name = aiStringFrom(mat->GetName());
|
||||
out->AddProperty(&ai_name, AI_MATKEY_NAME);
|
||||
@@ -289,7 +289,7 @@ void C4DImporter::ReadMaterials(BaseMaterial* mat) {
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void C4DImporter::RecurseHierarchy(BaseObject* object, aiNode* parent) {
|
||||
ai_assert(parent != nullptr );
|
||||
NodeArray nodes;
|
||||
std::vector<aiNode*> nodes;
|
||||
|
||||
// based on Cineware sample code
|
||||
while (object) {
|
||||
@@ -577,7 +577,7 @@ aiMesh* C4DImporter::ReadMesh(BaseObject* object) {
|
||||
unsigned int C4DImporter::ResolveMaterial(PolygonObject* obj) {
|
||||
ai_assert(obj != nullptr);
|
||||
|
||||
const unsigned int mat_count = static_cast<unsigned int>(mMaterials.size());
|
||||
const unsigned int mat_count = static_cast<unsigned int>(materials.size());
|
||||
|
||||
BaseTag* tag = obj->GetTag(Ttexture);
|
||||
if(tag == nullptr) {
|
||||
|
||||
@@ -97,12 +97,11 @@ private:
|
||||
|
||||
bool ReadShader(aiMaterial* out, cineware::BaseShader* shader);
|
||||
|
||||
private:
|
||||
MeshArray mMeshes;
|
||||
MaterialArray materials;
|
||||
std::vector<aiMesh*> meshes;
|
||||
std::vector<aiMaterial*> materials;
|
||||
|
||||
using MaterialMap = std::map<cineware::BaseMaterial*, unsigned int> ;
|
||||
MaterialMap mMaterialMapping;
|
||||
typedef std::map<cineware::BaseMaterial*, unsigned int> MaterialMap;
|
||||
MaterialMap material_mapping;
|
||||
|
||||
}; // !class C4DImporter
|
||||
|
||||
|
||||
@@ -668,7 +668,7 @@ aiMesh *ColladaLoader::CreateMesh(const ColladaParser &pParser, const Mesh *pSrc
|
||||
}
|
||||
|
||||
// create morph target meshes if any
|
||||
MeshArray targetMeshes;
|
||||
std::vector<aiMesh *> targetMeshes;
|
||||
std::vector<float> targetWeights;
|
||||
Collada::MorphMethod method = Normalized;
|
||||
|
||||
|
||||
@@ -206,10 +206,10 @@ private:
|
||||
std::map<std::string, size_t> mMaterialIndexByName;
|
||||
|
||||
/** Accumulated meshes for the target scene */
|
||||
MeshArray mMeshes;
|
||||
std::vector<aiMesh *> mMeshes;
|
||||
|
||||
/** Accumulated morph target meshes */
|
||||
MeshArray mTargetMeshes;
|
||||
std::vector<aiMesh *> mTargetMeshes;
|
||||
|
||||
/** Temporary material list */
|
||||
std::vector<std::pair<Collada::Effect *, aiMaterial *>> newMats;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace FBX {
|
||||
|
||||
using namespace Util;
|
||||
|
||||
static constexpr char MAGIC_NODE_TAG[] = "_$AssimpFbx$";
|
||||
#define MAGIC_NODE_TAG "_$AssimpFbx$"
|
||||
|
||||
#define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000LL
|
||||
|
||||
@@ -125,10 +125,21 @@ static void correctRootTransform(const aiScene *scene) {
|
||||
|
||||
FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) :
|
||||
defaultMaterialIndex(),
|
||||
mMeshes(),
|
||||
lights(),
|
||||
cameras(),
|
||||
textures(),
|
||||
materials_converted(),
|
||||
textures_converted(),
|
||||
meshes_converted(),
|
||||
node_anim_chain_bits(),
|
||||
mNodeNames(),
|
||||
anim_fps(),
|
||||
mSceneOut(out),
|
||||
doc(doc),
|
||||
mRemoveEmptyBones(removeEmptyBones) {
|
||||
|
||||
|
||||
// animations need to be converted first since this will
|
||||
// populate the node_anim_chain_bits map, which is needed
|
||||
// to determine which nodes need to be generated.
|
||||
@@ -151,7 +162,7 @@ FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBo
|
||||
continue;
|
||||
}
|
||||
|
||||
auto mat = dynamic_cast<const Material *>(ob);
|
||||
const Material *mat = dynamic_cast<const Material *>(ob);
|
||||
if (mat) {
|
||||
|
||||
if (materials_converted.find(mat) == materials_converted.end()) {
|
||||
@@ -211,6 +222,7 @@ static std::string getAncestorBaseName(const aiNode *node) {
|
||||
return std::string(nodeName, length);
|
||||
}
|
||||
|
||||
// Make unique name
|
||||
std::string FBXConverter::MakeUniqueNodeName(const Model *const model, const aiNode &parent) {
|
||||
std::string original_name = FixNodeName(model->Name());
|
||||
if (original_name.empty()) {
|
||||
@@ -224,18 +236,9 @@ std::string FBXConverter::MakeUniqueNodeName(const Model *const model, const aiN
|
||||
/// This struct manages nodes which may or may not end up in the node hierarchy.
|
||||
/// When a node becomes a child of another node, that node becomes its owner and mOwnership should be released.
|
||||
struct FBXConverter::PotentialNode {
|
||||
PotentialNode() : mOwnership(new aiNode), mNode(mOwnership.get()) {
|
||||
// empty
|
||||
}
|
||||
|
||||
explicit PotentialNode(const std::string& name) : mOwnership(new aiNode(name)), mNode(mOwnership.get()) {
|
||||
// empty
|
||||
}
|
||||
|
||||
aiNode* operator->() {
|
||||
return mNode;
|
||||
}
|
||||
|
||||
PotentialNode() : mOwnership(new aiNode), mNode(mOwnership.get()) {}
|
||||
PotentialNode(const std::string& name) : mOwnership(new aiNode(name)), mNode(mOwnership.get()) {}
|
||||
aiNode* operator->() { return mNode; }
|
||||
std::unique_ptr<aiNode> mOwnership;
|
||||
aiNode* mNode;
|
||||
};
|
||||
@@ -1089,14 +1092,14 @@ aiMesh *FBXConverter::SetupEmptyMesh(const Geometry &mesh, aiNode *parent) {
|
||||
}
|
||||
|
||||
static aiSkeleton *createAiSkeleton(SkeletonBoneContainer &sbc) {
|
||||
if (sbc.meshArray.empty() || sbc.skeletonBoneToMeshLookup.empty()) {
|
||||
if (sbc.MeshArray.empty() || sbc.SkeletonBoneToMeshLookup.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
aiSkeleton *skeleton = new aiSkeleton;
|
||||
for (auto *mesh : sbc.meshArray) {
|
||||
auto it = sbc.skeletonBoneToMeshLookup.find(mesh);
|
||||
if (it == sbc.skeletonBoneToMeshLookup.end()) {
|
||||
for (auto *mesh : sbc.MeshArray) {
|
||||
auto it = sbc.SkeletonBoneToMeshLookup.find(mesh);
|
||||
if (it == sbc.SkeletonBoneToMeshLookup.end()) {
|
||||
continue;
|
||||
}
|
||||
SkeletonBoneArray *ba = it->second;
|
||||
@@ -1544,12 +1547,12 @@ static void copyBoneToSkeletonBone(aiMesh *mesh, aiBone *bone, aiSkeletonBone *s
|
||||
void FBXConverter::ConvertWeightsToSkeleton(aiMesh *out, const MeshGeometry &geo, const aiMatrix4x4 &absolute_transform, aiNode *parent, unsigned int materialIndex,
|
||||
std::vector<unsigned int> *outputVertStartIndices, SkeletonBoneContainer &skeletonContainer) {
|
||||
|
||||
if (skeletonContainer.skeletonBoneToMeshLookup.find(out) != skeletonContainer.skeletonBoneToMeshLookup.end()) {
|
||||
if (skeletonContainer.SkeletonBoneToMeshLookup.find(out) != skeletonContainer.SkeletonBoneToMeshLookup.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConvertWeights(out, geo, absolute_transform, parent, materialIndex, outputVertStartIndices);
|
||||
skeletonContainer.meshArray.emplace_back(out);
|
||||
skeletonContainer.MeshArray.emplace_back(out);
|
||||
SkeletonBoneArray *ba = new SkeletonBoneArray;
|
||||
for (size_t i = 0; i < out->mNumBones; ++i) {
|
||||
aiBone *bone = out->mBones[i];
|
||||
@@ -1560,7 +1563,7 @@ void FBXConverter::ConvertWeightsToSkeleton(aiMesh *out, const MeshGeometry &geo
|
||||
copyBoneToSkeletonBone(out, bone, skeletonBone);
|
||||
ba->emplace_back(skeletonBone);
|
||||
}
|
||||
skeletonContainer.skeletonBoneToMeshLookup[out] = ba;
|
||||
skeletonContainer.SkeletonBoneToMeshLookup[out] = ba;
|
||||
}
|
||||
|
||||
void FBXConverter::ConvertWeights(aiMesh *out, const MeshGeometry &geo, const aiMatrix4x4 &absolute_transform,
|
||||
@@ -1568,6 +1571,8 @@ void FBXConverter::ConvertWeights(aiMesh *out, const MeshGeometry &geo, const ai
|
||||
std::vector<unsigned int> *outputVertStartIndices) {
|
||||
ai_assert(geo.DeformerSkin());
|
||||
|
||||
std::vector<size_t> out_indices, index_out_indices, count_out_indices;
|
||||
|
||||
const Skin &sk = *geo.DeformerSkin();
|
||||
|
||||
std::vector<aiBone*> bones;
|
||||
@@ -1575,10 +1580,6 @@ void FBXConverter::ConvertWeights(aiMesh *out, const MeshGeometry &geo, const ai
|
||||
ai_assert(no_mat_check || outputVertStartIndices);
|
||||
|
||||
try {
|
||||
std::vector<size_t> count_out_indices;
|
||||
std::vector<size_t> index_out_indices;
|
||||
std::vector<size_t> out_indices;
|
||||
|
||||
// iterate over the sub deformers
|
||||
for (const Cluster *cluster : sk.Clusters()) {
|
||||
ai_assert(cluster);
|
||||
@@ -1750,10 +1751,10 @@ unsigned int FBXConverter::GetDefaultMaterial() {
|
||||
return defaultMaterialIndex - 1;
|
||||
}
|
||||
|
||||
auto out_mat = new aiMaterial();
|
||||
aiMaterial *out_mat = new aiMaterial();
|
||||
materials.push_back(out_mat);
|
||||
|
||||
const auto diffuse = aiColor3D(0.8f, 0.8f, 0.8f);
|
||||
const aiColor3D diffuse = aiColor3D(0.8f, 0.8f, 0.8f);
|
||||
out_mat->AddProperty(&diffuse, 1, AI_MATKEY_COLOR_DIFFUSE);
|
||||
|
||||
aiString s;
|
||||
@@ -1769,7 +1770,7 @@ unsigned int FBXConverter::ConvertMaterial(const Material &material, const MeshG
|
||||
const PropertyTable &props = material.Props();
|
||||
|
||||
// generate empty output material
|
||||
auto out_mat = new aiMaterial();
|
||||
aiMaterial *out_mat = new aiMaterial();
|
||||
materials_converted[&material] = static_cast<unsigned int>(materials.size());
|
||||
|
||||
materials.push_back(out_mat);
|
||||
@@ -1808,7 +1809,7 @@ unsigned int FBXConverter::ConvertMaterial(const Material &material, const MeshG
|
||||
|
||||
unsigned int FBXConverter::ConvertVideo(const Video &video) {
|
||||
// generate empty output texture
|
||||
auto out_tex = new aiTexture();
|
||||
aiTexture *out_tex = new aiTexture();
|
||||
textures.push_back(out_tex);
|
||||
|
||||
// assuming the texture is compressed
|
||||
|
||||
@@ -80,8 +80,8 @@ using SkeletonBoneArray = std::vector<aiSkeletonBone *>;
|
||||
using SkeletonBoneToMesh = std::map<aiMesh*, SkeletonBoneArray*>;
|
||||
|
||||
struct SkeletonBoneContainer {
|
||||
MeshArray meshArray;
|
||||
SkeletonBoneToMesh skeletonBoneToMeshLookup;
|
||||
std::vector<aiMesh *> MeshArray;
|
||||
SkeletonBoneToMesh SkeletonBoneToMeshLookup;
|
||||
};
|
||||
|
||||
class Document;
|
||||
|
||||
@@ -162,7 +162,7 @@ aiMesh *IRRImporter::BuildSingleQuadMesh(const SkyboxVertex &v1,
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void IRRImporter::BuildSkybox(MeshArray &meshes, std::vector<aiMaterial *> materials) {
|
||||
void IRRImporter::BuildSkybox(std::vector<aiMesh *> &meshes, std::vector<aiMaterial *> materials) {
|
||||
// Update the material of the skybox - replace the name and disable shading for skyboxes.
|
||||
for (unsigned int i = 0; i < 6; ++i) {
|
||||
aiMaterial *out = (aiMaterial *)(*(materials.end() - (6 - i)));
|
||||
@@ -602,7 +602,7 @@ void SetupMapping(aiMaterial *mat, aiTextureMapping mode, const aiVector3D &axis
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void IRRImporter::GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene,
|
||||
BatchLoader &batch,
|
||||
MeshArray &meshes,
|
||||
std::vector<aiMesh *> &meshes,
|
||||
std::vector<aiNodeAnim *> &anims,
|
||||
std::vector<AttachmentInfo> &attach,
|
||||
std::vector<aiMaterial *> &materials,
|
||||
@@ -1283,7 +1283,7 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
std::vector<aiNodeAnim *> anims;
|
||||
std::vector<aiMaterial *> materials;
|
||||
std::vector<AttachmentInfo> attach;
|
||||
MeshArray meshes;
|
||||
std::vector<aiMesh *> meshes;
|
||||
|
||||
// try to guess how much storage we'll need
|
||||
anims.reserve(guessedAnimCnt + (guessedAnimCnt >> 2));
|
||||
|
||||
@@ -229,7 +229,7 @@ private:
|
||||
/// Fill the scene-graph recursively
|
||||
void GenerateGraph(Node *root, aiNode *rootOut, aiScene *scene,
|
||||
BatchLoader &batch,
|
||||
MeshArray &meshes,
|
||||
std::vector<aiMesh *> &meshes,
|
||||
std::vector<aiNodeAnim *> &anims,
|
||||
std::vector<AttachmentInfo> &attach,
|
||||
std::vector<aiMaterial *> &materials,
|
||||
@@ -248,7 +248,7 @@ private:
|
||||
/// @param meshes Receives 6 output meshes
|
||||
/// @param materials The last 6 materials are assigned to the newly
|
||||
/// created meshes. The names of the materials are adjusted.
|
||||
void BuildSkybox(MeshArray &meshes,
|
||||
void BuildSkybox(std::vector<aiMesh *> &meshes,
|
||||
std::vector<aiMaterial *> materials);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@@ -121,7 +121,7 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
|
||||
|
||||
// final data
|
||||
std::vector<aiMaterial *> materials;
|
||||
MeshArray meshes;
|
||||
std::vector<aiMesh *> meshes;
|
||||
materials.reserve(5);
|
||||
meshes.reserve(5);
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ void LWOImporter::InternReadFile(const std::string &pFile,
|
||||
ResolveClips();
|
||||
|
||||
// now process all layers and build meshes and nodes
|
||||
MeshArray apcMeshes;
|
||||
std::vector<aiMesh *> apcMeshes;
|
||||
std::map<uint16_t, aiNode *> apcNodes;
|
||||
|
||||
apcMeshes.reserve(mLayers->size() * std::min(((unsigned int)mSurfaces->size() / 2u), 1u));
|
||||
|
||||
@@ -1405,10 +1405,10 @@ void MDLImporter::InternReadFile_3DGS_MDL7() {
|
||||
sharedData.apcOutBones = this->LoadBones_3DGS_MDL7();
|
||||
|
||||
// vector to held all created meshes
|
||||
MeshArray *avOutList;
|
||||
std::vector<aiMesh *> *avOutList;
|
||||
|
||||
// 3 meshes per group - that should be OK for most models
|
||||
avOutList = new MeshArray[pcHeader->groups_num];
|
||||
avOutList = new std::vector<aiMesh *>[pcHeader->groups_num];
|
||||
for (uint32_t i = 0; i < pcHeader->groups_num; ++i)
|
||||
avOutList[i].reserve(3);
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ void Q3BSPFileImporter::CreateNodes(const Q3BSP::Q3BSPModel *pModel, aiScene *pS
|
||||
}
|
||||
|
||||
unsigned int matIdx(0);
|
||||
MeshArray MeshArray;
|
||||
std::vector<aiMesh *> MeshArray;
|
||||
std::vector<aiNode *> NodeArray;
|
||||
for (FaceMapIt it = m_MaterialLookupMap.begin(); it != m_MaterialLookupMap.end(); ++it) {
|
||||
std::vector<Q3BSP::sQ3BSPFace *> *pArray = (*it).second;
|
||||
|
||||
@@ -116,7 +116,7 @@ struct SIBObject {
|
||||
|
||||
struct SIB {
|
||||
std::vector<aiMaterial *> mtls;
|
||||
MeshArray meshes;
|
||||
std::vector<aiMesh *> meshes;
|
||||
std::vector<aiLight *> lights;
|
||||
std::vector<SIBObject> objs, insts;
|
||||
};
|
||||
|
||||
@@ -222,7 +222,7 @@ void STLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Read an ASCII STL file
|
||||
void STLImporter::LoadASCIIFile(aiNode *root) {
|
||||
MeshArray meshes;
|
||||
std::vector<aiMesh *> meshes;
|
||||
std::vector<aiNode *> nodes;
|
||||
const char *sz = mBuffer;
|
||||
const char *bufferEnd = mBuffer + mFileSize;
|
||||
|
||||
@@ -219,7 +219,7 @@ void XFileImporter::CreateMeshes(aiScene *pScene, aiNode *pNode, const std::vect
|
||||
}
|
||||
|
||||
// create a mesh for each mesh-material combination in the source node
|
||||
MeshArray meshes;
|
||||
std::vector<aiMesh *> meshes;
|
||||
for (unsigned int a = 0; a < pMeshes.size(); ++a) {
|
||||
XFile::Mesh *sourceMesh = pMeshes[a];
|
||||
if (nullptr == sourceMesh) {
|
||||
|
||||
@@ -139,7 +139,7 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||
ReadWorld(*worldNode, scope);
|
||||
}
|
||||
|
||||
MeshArray &meshes = scope.meshes_linear;
|
||||
std::vector<aiMesh *> &meshes = scope.meshes_linear;
|
||||
std::vector<aiMaterial *> &materials = scope.materials_linear;
|
||||
if (meshes.empty() || materials.empty()) {
|
||||
ThrowException("failed to extract data from XGL file, no meshes loaded");
|
||||
|
||||
@@ -192,7 +192,7 @@ static bool CheckValidFacesIndices(const aiFace *faces, unsigned nFaces, unsigne
|
||||
}
|
||||
|
||||
void glTFImporter::ImportMeshes(Asset &r) {
|
||||
MeshArray meshes;
|
||||
std::vector<aiMesh *> meshes;
|
||||
|
||||
unsigned int k = 0;
|
||||
meshOffsets.clear();
|
||||
|
||||
@@ -678,8 +678,8 @@ void SceneCombiner::MergeScenes(aiScene **_dest, aiScene *master, std::vector<At
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Build a list of unique bones
|
||||
void SceneCombiner::BuildUniqueBoneList(std::list<BoneWithHash> &asBones,
|
||||
MeshArray::const_iterator it,
|
||||
MeshArray::const_iterator end) {
|
||||
std::vector<aiMesh *>::const_iterator it,
|
||||
std::vector<aiMesh *>::const_iterator end) {
|
||||
unsigned int iOffset = 0;
|
||||
for (; it != end; ++it) {
|
||||
for (unsigned int l = 0; l < (*it)->mNumBones; ++l) {
|
||||
@@ -712,7 +712,8 @@ void SceneCombiner::BuildUniqueBoneList(std::list<BoneWithHash> &asBones,
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Merge a list of bones
|
||||
void SceneCombiner::MergeBones(aiMesh *out, MeshArray::const_iterator it, MeshArray::const_iterator end) {
|
||||
void SceneCombiner::MergeBones(aiMesh *out, std::vector<aiMesh *>::const_iterator it,
|
||||
std::vector<aiMesh *>::const_iterator end) {
|
||||
if (nullptr == out || out->mNumBones == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -770,8 +771,8 @@ void SceneCombiner::MergeBones(aiMesh *out, MeshArray::const_iterator it, MeshAr
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Merge a list of meshes
|
||||
void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
MeshArray::const_iterator begin,
|
||||
MeshArray::const_iterator end) {
|
||||
std::vector<aiMesh *>::const_iterator begin,
|
||||
std::vector<aiMesh *>::const_iterator end) {
|
||||
if (nullptr == _out) {
|
||||
return;
|
||||
}
|
||||
@@ -787,7 +788,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
|
||||
std::string name;
|
||||
// Find out how much output storage we'll need
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it) {
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it) {
|
||||
const char *meshName((*it)->mName.C_Str());
|
||||
name += std::string(meshName);
|
||||
if (it != end - 1) {
|
||||
@@ -809,7 +810,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
if ((**begin).HasPositions()) {
|
||||
|
||||
pv2 = out->mVertices = new aiVector3D[out->mNumVertices];
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it) {
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it) {
|
||||
if ((*it)->mVertices) {
|
||||
::memcpy(pv2, (*it)->mVertices, (*it)->mNumVertices * sizeof(aiVector3D));
|
||||
} else
|
||||
@@ -821,7 +822,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
if ((**begin).HasNormals()) {
|
||||
|
||||
pv2 = out->mNormals = new aiVector3D[out->mNumVertices];
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it) {
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it) {
|
||||
if ((*it)->mNormals) {
|
||||
::memcpy(pv2, (*it)->mNormals, (*it)->mNumVertices * sizeof(aiVector3D));
|
||||
} else {
|
||||
@@ -836,7 +837,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
pv2 = out->mTangents = new aiVector3D[out->mNumVertices];
|
||||
aiVector3D *pv2b = out->mBitangents = new aiVector3D[out->mNumVertices];
|
||||
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it) {
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it) {
|
||||
if ((*it)->mTangents) {
|
||||
::memcpy(pv2, (*it)->mTangents, (*it)->mNumVertices * sizeof(aiVector3D));
|
||||
::memcpy(pv2b, (*it)->mBitangents, (*it)->mNumVertices * sizeof(aiVector3D));
|
||||
@@ -853,7 +854,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
out->mNumUVComponents[n] = (*begin)->mNumUVComponents[n];
|
||||
|
||||
pv2 = out->mTextureCoords[n] = new aiVector3D[out->mNumVertices];
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it) {
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it) {
|
||||
if ((*it)->mTextureCoords[n]) {
|
||||
::memcpy(pv2, (*it)->mTextureCoords[n], (*it)->mNumVertices * sizeof(aiVector3D));
|
||||
} else {
|
||||
@@ -867,7 +868,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
n = 0;
|
||||
while ((**begin).HasVertexColors(n)) {
|
||||
aiColor4D *pVec2 = out->mColors[n] = new aiColor4D[out->mNumVertices];
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it) {
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it) {
|
||||
if ((*it)->mColors[n]) {
|
||||
::memcpy(pVec2, (*it)->mColors[n], (*it)->mNumVertices * sizeof(aiColor4D));
|
||||
} else {
|
||||
@@ -886,7 +887,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
aiFace *pf2 = out->mFaces;
|
||||
|
||||
unsigned int ofs = 0;
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it) {
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it) {
|
||||
for (unsigned int m = 0; m < (*it)->mNumFaces; ++m, ++pf2) {
|
||||
aiFace &face = (*it)->mFaces[m];
|
||||
pf2->mNumIndices = face.mNumIndices;
|
||||
@@ -909,7 +910,7 @@ void SceneCombiner::MergeMeshes(aiMesh **_out, unsigned int /*flags*/,
|
||||
MergeBones(out, begin, end);
|
||||
|
||||
// delete all source meshes
|
||||
for (MeshArray::const_iterator it = begin; it != end; ++it)
|
||||
for (std::vector<aiMesh *>::const_iterator it = begin; it != end; ++it)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,8 @@ void CatmullClarkSubdivider::Subdivide(
|
||||
return;
|
||||
}
|
||||
|
||||
MeshArray inmeshes;
|
||||
MeshArray outmeshes;
|
||||
std::vector<aiMesh *> inmeshes;
|
||||
std::vector<aiMesh *> outmeshes;
|
||||
std::vector<unsigned int> maptbl;
|
||||
|
||||
inmeshes.reserve(nmesh);
|
||||
@@ -577,7 +577,7 @@ void CatmullClarkSubdivider::InternSubdivide(
|
||||
// 7. Apply the next subdivision step.
|
||||
// ---------------------------------------------------------------------
|
||||
if (num != 1) {
|
||||
MeshArray tmp(nmesh);
|
||||
std::vector<aiMesh *> tmp(nmesh);
|
||||
InternSubdivide(out, nmesh, &tmp.front(), num - 1);
|
||||
for (size_t i = 0; i < nmesh; ++i) {
|
||||
delete out[i];
|
||||
|
||||
@@ -332,7 +332,7 @@ void PretransformVertices::ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Simple routine to build meshes in worldspace, no further optimization
|
||||
void PretransformVertices::BuildWCSMeshes(MeshArray &out, aiMesh **in,
|
||||
void PretransformVertices::BuildWCSMeshes(std::vector<aiMesh *> &out, aiMesh **in,
|
||||
unsigned int numIn, aiNode *node) const {
|
||||
// NOTE:
|
||||
// aiMesh::mNumBones store original source mesh, or UINT_MAX if not a copy
|
||||
@@ -459,7 +459,7 @@ void PretransformVertices::Execute(aiScene *pScene) {
|
||||
}
|
||||
|
||||
// now build a list of output meshes
|
||||
MeshArray apcOutMeshes;
|
||||
std::vector<aiMesh *> apcOutMeshes;
|
||||
|
||||
// Keep scene hierarchy? It's an easy job in this case ...
|
||||
// we go on and transform all meshes, if one is referenced by nodes
|
||||
|
||||
@@ -139,7 +139,7 @@ private:
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Simple routine to build meshes in worldspace, no further optimization
|
||||
void BuildWCSMeshes(MeshArray &out, aiMesh **in,
|
||||
void BuildWCSMeshes(std::vector<aiMesh *> &out, aiMesh **in,
|
||||
unsigned int numIn, aiNode *node) const;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@@ -126,7 +126,7 @@ void SortByPTypeProcess::Execute(aiScene *pScene) {
|
||||
|
||||
unsigned int aiNumMeshesPerPType[4] = { 0, 0, 0, 0 };
|
||||
|
||||
MeshArray outMeshes;
|
||||
std::vector<aiMesh *> outMeshes;
|
||||
outMeshes.reserve(static_cast<size_t>(pScene->mNumMeshes) << 1u);
|
||||
|
||||
bool bAnyChanges = false;
|
||||
|
||||
@@ -58,7 +58,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <assimp/types.h>
|
||||
|
||||
#include <exception>
|
||||
#include <vector>
|
||||
|
||||
namespace Assimp {
|
||||
// =======================================================================
|
||||
@@ -68,7 +67,6 @@ class IOStream;
|
||||
class IOSystem;
|
||||
class ProgressHandler;
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// Plugin development
|
||||
//
|
||||
|
||||
@@ -240,8 +240,8 @@ public:
|
||||
* @param end Points to the mesh after the last mesh to be processed
|
||||
*/
|
||||
static void MergeMeshes(aiMesh **dest, unsigned int flags,
|
||||
MeshArray::const_iterator begin,
|
||||
MeshArray::const_iterator end);
|
||||
std::vector<aiMesh *>::const_iterator begin,
|
||||
std::vector<aiMesh *>::const_iterator end);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Merges two or more bones
|
||||
@@ -251,8 +251,8 @@ public:
|
||||
* @param begin First mesh to be processed
|
||||
* @param end Points to the mesh after the last mesh to be processed
|
||||
*/
|
||||
static void MergeBones(aiMesh *out, MeshArray::const_iterator it,
|
||||
MeshArray::const_iterator end);
|
||||
static void MergeBones(aiMesh *out, std::vector<aiMesh *>::const_iterator it,
|
||||
std::vector<aiMesh *>::const_iterator end);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Merges two or more materials
|
||||
@@ -277,8 +277,8 @@ public:
|
||||
* @param end Last mesh to be processed
|
||||
*/
|
||||
static void BuildUniqueBoneList(std::list<BoneWithHash> &asBones,
|
||||
MeshArray::const_iterator it,
|
||||
MeshArray::const_iterator end);
|
||||
std::vector<aiMesh *>::const_iterator it,
|
||||
std::vector<aiMesh *>::const_iterator end);
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/** Add a name prefix to all nodes in a scene.
|
||||
|
||||
@@ -77,17 +77,6 @@ typedef uint32_t ai_uint32;
|
||||
#include <new> // for std::nothrow_t
|
||||
#include <string> // for aiString::Set(const std::string&)
|
||||
|
||||
struct aiNode;
|
||||
struct aiMesh;
|
||||
struct aiMaterial;
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
using MeshArray = std::vector<aiMesh *>;
|
||||
using NodeArray = std::vector<aiNode *>;
|
||||
using MaterialArray = std::vector<aiMaterial*>;
|
||||
|
||||
namespace Assimp {
|
||||
//! @cond never
|
||||
namespace Intern {
|
||||
|
||||
@@ -50,7 +50,7 @@ class utSceneCombiner : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(utSceneCombiner, MergeMeshes_ValidNames_Test) {
|
||||
MeshArray merge_list;
|
||||
std::vector<aiMesh *> merge_list;
|
||||
aiMesh *mesh1 = new aiMesh;
|
||||
mesh1->mName.Set("mesh_1");
|
||||
merge_list.push_back(mesh1);
|
||||
|
||||
Reference in New Issue
Block a user