- fbx: fix memleak in exception cases.
parent
916947327f
commit
23c62f07f7
|
@ -129,41 +129,45 @@ private:
|
||||||
std::vector<aiNode*> nodes;
|
std::vector<aiNode*> nodes;
|
||||||
nodes.reserve(conns.size());
|
nodes.reserve(conns.size());
|
||||||
|
|
||||||
BOOST_FOREACH(const Connection* con, conns) {
|
try {
|
||||||
|
BOOST_FOREACH(const Connection* con, conns) {
|
||||||
|
|
||||||
// ignore object-property links
|
// ignore object-property links
|
||||||
if(con->PropertyName().length()) {
|
if(con->PropertyName().length()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Object* const object = con->SourceObject();
|
||||||
|
if(!object) {
|
||||||
|
FBXImporter::LogWarn("failed to convert source object for Model link");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Model* const model = dynamic_cast<const Model*>(object);
|
||||||
|
|
||||||
|
if(model) {
|
||||||
|
aiNode* nd = new aiNode();
|
||||||
|
nodes.push_back(nd);
|
||||||
|
|
||||||
|
nd->mName.Set(FixNodeName(model->Name()));
|
||||||
|
nd->mParent = &parent;
|
||||||
|
|
||||||
|
ConvertTransformation(*model,*nd);
|
||||||
|
|
||||||
|
ConvertModel(*model, *nd);
|
||||||
|
ConvertNodes(model->ID(), *nd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Object* const object = con->SourceObject();
|
if(nodes.size()) {
|
||||||
if(!object) {
|
parent.mChildren = new aiNode*[nodes.size()]();
|
||||||
FBXImporter::LogWarn("failed to convert source object for node link");
|
parent.mNumChildren = static_cast<unsigned int>(nodes.size());
|
||||||
continue;
|
|
||||||
|
std::swap_ranges(nodes.begin(),nodes.end(),parent.mChildren);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
const Model* const model = dynamic_cast<const Model*>(object);
|
catch(std::exception&) {
|
||||||
|
std::for_each(nodes.begin(),nodes.end(),Util::delete_fun<aiNode>());
|
||||||
|
|
||||||
if(model) {
|
|
||||||
aiNode* nd = new aiNode();
|
|
||||||
nodes.push_back(nd);
|
|
||||||
|
|
||||||
nd->mName.Set(FixNodeName(model->Name()));
|
|
||||||
nd->mParent = &parent;
|
|
||||||
|
|
||||||
ConvertTransformation(*model,*nd);
|
|
||||||
|
|
||||||
ConvertModel(*model, *nd);
|
|
||||||
ConvertNodes(model->ID(), *nd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nodes.size()) {
|
|
||||||
parent.mChildren = new aiNode*[nodes.size()]();
|
|
||||||
parent.mNumChildren = static_cast<unsigned int>(nodes.size());
|
|
||||||
|
|
||||||
std::swap_ranges(nodes.begin(),nodes.end(),parent.mChildren);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +177,8 @@ private:
|
||||||
{
|
{
|
||||||
const PropertyTable& props = model.Props();
|
const PropertyTable& props = model.Props();
|
||||||
|
|
||||||
|
// XXX this is not complete, need to handle rotation and scaling pivots etc
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
aiVector3D Translation = PropertyGet<aiVector3D>(props,"Lcl Translation",ok);
|
aiVector3D Translation = PropertyGet<aiVector3D>(props,"Lcl Translation",ok);
|
||||||
|
@ -640,7 +646,7 @@ private:
|
||||||
bones.reserve(sk.Clusters().size());
|
bones.reserve(sk.Clusters().size());
|
||||||
|
|
||||||
const bool no_mat_check = materialIndex == NO_MATERIAL_SEPARATION;
|
const bool no_mat_check = materialIndex == NO_MATERIAL_SEPARATION;
|
||||||
ai_assert(!no_mat_check || outputVertStartIndices);
|
ai_assert(no_mat_check || outputVertStartIndices);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue