More reduced scope fix by wasting more memory...
parent
5b18baf883
commit
1c23d2e8de
|
@ -264,7 +264,7 @@ uint32_t M3DExporter::mkColor(aiColor4D* c)
|
||||||
// add a material to the output
|
// add a material to the output
|
||||||
M3D_INDEX M3DExporter::addMaterial(const aiMaterial *mat)
|
M3D_INDEX M3DExporter::addMaterial(const aiMaterial *mat)
|
||||||
{
|
{
|
||||||
unsigned int i, mi = -1U;
|
unsigned int mi = -1U;
|
||||||
aiColor4D c;
|
aiColor4D c;
|
||||||
aiString name;
|
aiString name;
|
||||||
ai_real f;
|
ai_real f;
|
||||||
|
@ -274,13 +274,14 @@ M3D_INDEX M3DExporter::addMaterial(const aiMaterial *mat)
|
||||||
strcmp((char*)&name.data, AI_DEFAULT_MATERIAL_NAME)) {
|
strcmp((char*)&name.data, AI_DEFAULT_MATERIAL_NAME)) {
|
||||||
// check if we have saved a material by this name. This has to be done
|
// check if we have saved a material by this name. This has to be done
|
||||||
// because only the referenced materials should be added to the output
|
// because only the referenced materials should be added to the output
|
||||||
for(i = 0; i < m3d->nummaterial; i++)
|
for(unsigned int i = 0; i < m3d->nummaterial; i++)
|
||||||
if(!strcmp((char*)&name.data, m3d->material[i].name)) {
|
if(!strcmp((char*)&name.data, m3d->material[i].name)) {
|
||||||
mi = i;
|
mi = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if not found, add the material to the output
|
// if not found, add the material to the output
|
||||||
if(mi == -1U) {
|
if(mi == -1U) {
|
||||||
|
unsigned int k;
|
||||||
mi = m3d->nummaterial++;
|
mi = m3d->nummaterial++;
|
||||||
m3d->material = (m3dm_t*)M3D_REALLOC(m3d->material, m3d->nummaterial
|
m3d->material = (m3dm_t*)M3D_REALLOC(m3d->material, m3d->nummaterial
|
||||||
* sizeof(m3dm_t));
|
* sizeof(m3dm_t));
|
||||||
|
@ -291,9 +292,7 @@ M3D_INDEX M3DExporter::addMaterial(const aiMaterial *mat)
|
||||||
m3d->material[mi].numprop = 0;
|
m3d->material[mi].numprop = 0;
|
||||||
m3d->material[mi].prop = NULL;
|
m3d->material[mi].prop = NULL;
|
||||||
// iterate through the material property table and see what we got
|
// iterate through the material property table and see what we got
|
||||||
for(unsigned int k = 0;
|
for(k = 0; k < 15; k++) {
|
||||||
k < sizeof(m3d_propertytypes)/sizeof(m3d_propertytypes[0]);
|
|
||||||
k++) {
|
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
if(m3d_propertytypes[k].format == m3dpf_map)
|
if(m3d_propertytypes[k].format == m3dpf_map)
|
||||||
continue;
|
continue;
|
||||||
|
@ -341,6 +340,7 @@ M3D_INDEX M3DExporter::addMaterial(const aiMaterial *mat)
|
||||||
mat->GetTexture((aiTextureType)aiTxProps[k].type,
|
mat->GetTexture((aiTextureType)aiTxProps[k].type,
|
||||||
aiTxProps[k].index, &name, NULL, NULL, NULL,
|
aiTxProps[k].index, &name, NULL, NULL, NULL,
|
||||||
NULL, NULL) == AI_SUCCESS) {
|
NULL, NULL) == AI_SUCCESS) {
|
||||||
|
unsigned int i;
|
||||||
for(j = name.length-1; j > 0 && name.data[j]!='.'; j++);
|
for(j = name.length-1; j > 0 && name.data[j]!='.'; j++);
|
||||||
if(j && name.data[j]=='.' &&
|
if(j && name.data[j]=='.' &&
|
||||||
(name.data[j+1]=='p' || name.data[j+1]=='P') &&
|
(name.data[j+1]=='p' || name.data[j+1]=='P') &&
|
||||||
|
|
|
@ -629,7 +629,6 @@ void M3DImporter::calculateOffsetMatrix(aiNode *pNode, aiMatrix4x4 *m)
|
||||||
void M3DImporter::populateMesh(aiMesh *pMesh, std::vector<aiFace> *faces, std::vector<aiVector3D> *vertices,
|
void M3DImporter::populateMesh(aiMesh *pMesh, std::vector<aiFace> *faces, std::vector<aiVector3D> *vertices,
|
||||||
std::vector<aiVector3D> *normals, std::vector<aiVector3D> *texcoords, std::vector<aiColor4D> *colors,
|
std::vector<aiVector3D> *normals, std::vector<aiVector3D> *texcoords, std::vector<aiColor4D> *colors,
|
||||||
std::vector<unsigned int> *vertexids) {
|
std::vector<unsigned int> *vertexids) {
|
||||||
unsigned int i, j;
|
|
||||||
|
|
||||||
ai_assert(pMesh != nullptr);
|
ai_assert(pMesh != nullptr);
|
||||||
ai_assert(faces != nullptr);
|
ai_assert(faces != nullptr);
|
||||||
|
@ -644,6 +643,7 @@ void M3DImporter::populateMesh(aiMesh *pMesh, std::vector<aiFace> *faces, std::v
|
||||||
" numnormals ", normals->size(), " numtexcoord ", texcoords->size(), " numbones ", m3d->numbone);
|
" numnormals ", normals->size(), " numtexcoord ", texcoords->size(), " numbones ", m3d->numbone);
|
||||||
|
|
||||||
if(vertices->size() && faces->size()) {
|
if(vertices->size() && faces->size()) {
|
||||||
|
unsigned int i;
|
||||||
pMesh->mNumFaces = faces->size();
|
pMesh->mNumFaces = faces->size();
|
||||||
pMesh->mFaces = new aiFace[pMesh->mNumFaces];
|
pMesh->mFaces = new aiFace[pMesh->mNumFaces];
|
||||||
std::copy(faces->begin(), faces->end(), pMesh->mFaces);
|
std::copy(faces->begin(), faces->end(), pMesh->mFaces);
|
||||||
|
@ -682,11 +682,12 @@ void M3DImporter::populateMesh(aiMesh *pMesh, std::vector<aiFace> *faces, std::v
|
||||||
pMesh->mBones[i]->mOffsetMatrix = aiMatrix4x4();
|
pMesh->mBones[i]->mOffsetMatrix = aiMatrix4x4();
|
||||||
}
|
}
|
||||||
if(vertexids->size()) {
|
if(vertexids->size()) {
|
||||||
|
unsigned int j;
|
||||||
// first count how many vertices we have per bone
|
// first count how many vertices we have per bone
|
||||||
for(i = 0; i < vertexids->size(); i++) {
|
for(i = 0; i < vertexids->size(); i++) {
|
||||||
unsigned int s = m3d->vertex[vertexids->at(i)].skinid, k;
|
unsigned int s = m3d->vertex[vertexids->at(i)].skinid;
|
||||||
if(s != -1U && s!= -2U) {
|
if(s != -1U && s!= -2U) {
|
||||||
for(k = 0; k < M3D_NUMBONE && m3d->skin[s].weight[k] > 0.0; k++) {
|
for(unsigned int k = 0; k < M3D_NUMBONE && m3d->skin[s].weight[k] > 0.0; k++) {
|
||||||
aiString name = aiString(std::string(m3d->bone[m3d->skin[s].boneid[k]].name));
|
aiString name = aiString(std::string(m3d->bone[m3d->skin[s].boneid[k]].name));
|
||||||
for(j = 0; j < pMesh->mNumBones; j++) {
|
for(j = 0; j < pMesh->mNumBones; j++) {
|
||||||
if(pMesh->mBones[j]->mName == name) {
|
if(pMesh->mBones[j]->mName == name) {
|
||||||
|
@ -707,9 +708,9 @@ void M3DImporter::populateMesh(aiMesh *pMesh, std::vector<aiFace> *faces, std::v
|
||||||
}
|
}
|
||||||
// fill up with data
|
// fill up with data
|
||||||
for(i = 0; i < vertexids->size(); i++) {
|
for(i = 0; i < vertexids->size(); i++) {
|
||||||
unsigned int s = m3d->vertex[vertexids->at(i)].skinid, k;
|
unsigned int s = m3d->vertex[vertexids->at(i)].skinid;
|
||||||
if(s != -1U && s!= -2U) {
|
if(s != -1U && s!= -2U) {
|
||||||
for(k = 0; k < M3D_NUMBONE && m3d->skin[s].weight[k] > 0.0; k++) {
|
for(unsigned int k = 0; k < M3D_NUMBONE && m3d->skin[s].weight[k] > 0.0; k++) {
|
||||||
aiString name = aiString(std::string(m3d->bone[m3d->skin[s].boneid[k]].name));
|
aiString name = aiString(std::string(m3d->bone[m3d->skin[s].boneid[k]].name));
|
||||||
for(j = 0; j < pMesh->mNumBones; j++) {
|
for(j = 0; j < pMesh->mNumBones; j++) {
|
||||||
if(pMesh->mBones[j]->mName == name) {
|
if(pMesh->mBones[j]->mName == name) {
|
||||||
|
|
Loading…
Reference in New Issue