forked from bartvdbraak/blender
#collada instance_node import, partially fixes #27629
Patch applied in r37663 caused loss of <instance_node>s. All parts of the smaller test file attached in the report now import.
This commit is contained in:
parent
757c0af9c6
commit
8634d0e9c1
@ -121,8 +121,10 @@ bool DocumentImporter::import()
|
||||
|
||||
loader.registerExtraDataCallbackHandler(ehandler);
|
||||
|
||||
if (!root.loadDocument(mFilename))
|
||||
if (!root.loadDocument(mFilename)) {
|
||||
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(errorHandler.hasError())
|
||||
return false;
|
||||
@ -134,8 +136,10 @@ bool DocumentImporter::import()
|
||||
COLLADASaxFWL::Loader loader2;
|
||||
COLLADAFW::Root root2(&loader2, this);
|
||||
|
||||
if (!root2.loadDocument(mFilename))
|
||||
if (!root2.loadDocument(mFilename)) {
|
||||
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
delete ehandler;
|
||||
@ -313,7 +317,7 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce
|
||||
return ob;
|
||||
}
|
||||
|
||||
Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, Object *par_ob, bool is_library_node)
|
||||
Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node)
|
||||
{
|
||||
Object *obn = copy_object(source_ob);
|
||||
obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
|
||||
@ -357,10 +361,10 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
|
||||
Object *new_child = NULL;
|
||||
if (inodes.getCount()) { // \todo loop through instance nodes
|
||||
const COLLADAFW::UniqueId& id = inodes[0]->getInstanciatedObjectId();
|
||||
new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, NULL, is_library_node);
|
||||
new_child = create_instance_node(object_map[id], node_map[id], child_node, sce, is_library_node);
|
||||
}
|
||||
else {
|
||||
new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, NULL, is_library_node);
|
||||
new_child = create_instance_node(object_map[child_id], child_node, NULL, sce, is_library_node);
|
||||
}
|
||||
bc_set_parent(new_child, obn, mContext, true);
|
||||
|
||||
@ -369,21 +373,14 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod
|
||||
}
|
||||
}
|
||||
|
||||
// when we have an instance_node, don't return the object, because otherwise
|
||||
// its correct location gets overwritten in write_node(). Fixes bug #26012.
|
||||
if(instance_node) {
|
||||
if (par_ob && obn)
|
||||
bc_set_parent(obn, par_ob, mContext);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
else return obn;
|
||||
return obn;
|
||||
}
|
||||
|
||||
void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node)
|
||||
{
|
||||
Object *ob = NULL;
|
||||
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
|
||||
bool read_transform = true;
|
||||
|
||||
if (is_joint) {
|
||||
if ( par ) {
|
||||
@ -439,9 +436,11 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
|
||||
Object *source_ob = object_map[node_id];
|
||||
COLLADAFW::Node *source_node = node_map[node_id];
|
||||
|
||||
ob = create_instance_node(source_ob, source_node, node, sce, par, is_library_node);
|
||||
ob = create_instance_node(source_ob, source_node, node, sce, is_library_node);
|
||||
}
|
||||
++inst_done;
|
||||
|
||||
read_transform = false;
|
||||
}
|
||||
// if node is empty - create empty object
|
||||
// XXX empty node may not mean it is empty object, not sure about this
|
||||
@ -449,7 +448,8 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
|
||||
ob = add_object(sce, OB_EMPTY);
|
||||
}
|
||||
|
||||
// check if object is not NULL
|
||||
// XXX: if there're multiple instances, only one is stored
|
||||
|
||||
if (!ob) return;
|
||||
|
||||
std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId();
|
||||
@ -462,7 +462,8 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren
|
||||
libnode_ob.push_back(ob);
|
||||
}
|
||||
|
||||
anim_importer.read_node_transform(node, ob); // overwrites location set earlier
|
||||
if (read_transform)
|
||||
anim_importer.read_node_transform(node, ob); // overwrites location set earlier
|
||||
|
||||
if (!is_joint) {
|
||||
// if par was given make this object child of the previous
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
/** these should not be here */
|
||||
Object* create_camera_object(COLLADAFW::InstanceCamera*, Scene*);
|
||||
Object* create_lamp_object(COLLADAFW::InstanceLight*, Scene*);
|
||||
Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
|
||||
Object* create_instance_node(Object*, COLLADAFW::Node*, COLLADAFW::Node*, Scene*, bool);
|
||||
void write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
|
||||
MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&);
|
||||
void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*);
|
||||
|
@ -83,5 +83,9 @@ bool ErrorHandler::handleError( const COLLADASaxFWL::IError* error )
|
||||
COLLADASaxFWL::SaxFWLError* saxFWLError = (COLLADASaxFWL::SaxFWLError*) error;
|
||||
std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "opencollada error: " << error->getFullErrorMessage() << std::endl;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user