diff options
Diffstat (limited to 'source/blender/collada')
-rw-r--r-- | source/blender/collada/AnimationExporter.cpp | 2 | ||||
-rw-r--r-- | source/blender/collada/ArmatureImporter.cpp | 7 | ||||
-rw-r--r-- | source/blender/collada/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 17 | ||||
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 67 | ||||
-rw-r--r-- | source/blender/collada/ExportSettings.h | 1 | ||||
-rw-r--r-- | source/blender/collada/ImageExporter.cpp | 56 | ||||
-rw-r--r-- | source/blender/collada/ImageExporter.h | 1 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 39 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.h | 10 | ||||
-rw-r--r-- | source/blender/collada/collada.cpp | 5 | ||||
-rw-r--r-- | source/blender/collada/collada.h | 3 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.cpp | 9 |
13 files changed, 40 insertions, 178 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 3bff20e846b..707aaea0b65 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -938,7 +938,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj float ctime = BKE_scene_frame_get_from_ctime(scene, *it); CFRA = BKE_scene_frame_get_from_ctime(scene, *it); - //BKE_scene_update_for_newframe(G.main->eval_ctx, G.main,scene,scene->lay); + //BKE_scene_update_for_newframe(G.main->eval_ctx, G.main,scene); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); if (bone) { diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 0ea8324ed7c..9c8b8fc25d6 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -34,7 +34,6 @@ extern "C" { #include "BKE_action.h" -#include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_armature.h" #include "BLI_string.h" @@ -42,6 +41,8 @@ extern "C" { #include "ED_armature.h" } +#include "DEG_depsgraph.h" + #include "collada_utils.h" #include "ArmatureImporter.h" @@ -496,7 +497,7 @@ void ArmatureImporter::create_armature_bones(std::vector<Object *> &ob_arms) ob_arms.push_back(ob_arm); } - DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA); } } @@ -629,7 +630,7 @@ Object *ArmatureImporter::create_armature_bones(SkinInfo& skin) ED_armature_from_edit(armature); ED_armature_edit_free(armature); - DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA); return ob_arm; } diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 293049a1a05..8642bbee698 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -30,6 +30,7 @@ set(INC ../blenkernel ../blenlib ../blentranslation + ../depsgraph ../editors/include ../makesdna ../makesrna diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 226f319cefd..7cb6045b73e 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -57,12 +57,12 @@ extern "C" { #include "BLI_fileops.h" #include "BKE_camera.h" +#include "BKE_collection.h" #include "BKE_main.h" #include "BKE_lamp.h" #include "BKE_library.h" #include "BKE_texture.h" #include "BKE_fcurve.h" -#include "BKE_depsgraph.h" #include "BKE_scene.h" #include "BKE_global.h" #include "BKE_material.h" @@ -82,6 +82,9 @@ extern "C" { } +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "ExtraHandler.h" #include "ErrorHandler.h" #include "DocumentImporter.h" @@ -230,7 +233,7 @@ void DocumentImporter::finish() } // update scene - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL); } @@ -241,7 +244,7 @@ void DocumentImporter::finish() armature_importer.set_tags_map(this->uid_tags_map); armature_importer.make_armatures(mContext, *objects_to_scale); armature_importer.make_shape_keys(); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); #if 0 armature_importer.fix_animation(); @@ -264,7 +267,7 @@ void DocumentImporter::finish() for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) { Object *ob = *it; - Base *base = BKE_scene_base_find(sce, ob); + BaseLegacy *base = (BaseLegacy *)BKE_scene_base_find(sce, ob); if (base) { BLI_remlink(&sce->base, base); BKE_libblock_free_us(G.main, base->object); @@ -275,7 +278,7 @@ void DocumentImporter::finish() } libnode_ob.clear(); - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); } bc_match_scale(objects_to_scale, unit_converter, !this->import_settings->import_units); @@ -417,8 +420,8 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod fprintf(stderr, "create <instance_node> under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL); Object *obn = BKE_object_copy(G.main, source_ob); - DAG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); - BKE_scene_base_add(sce, obn); + DEG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + BKE_collection_object_add_from(sce, source_ob, obn); if (instance_node) { anim_importer.read_node_transform(instance_node, obn); diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 76b51148509..978d79077fe 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -66,7 +66,7 @@ EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettin bool EffectsExporter::hasEffects(Scene *sce) { - Base *base = (Base *)sce->base.first; + BaseLegacy *base = (BaseLegacy *)sce->base.first; while (base) { Object *ob = base->object; @@ -311,58 +311,6 @@ void EffectsExporter::operator()(Material *ma, Object *ob) } } - int active_uv_layer = -1; - std::set<Image *> uv_textures; - if (ob->type == OB_MESH && ob->totcol && this->export_settings->include_uv_textures) { - bool active_uv_only = this->export_settings->active_uv_only; - Mesh *me = (Mesh *) ob->data; - active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY); - - BKE_mesh_tessface_ensure(me); - for (int i = 0; i < me->pdata.totlayer; i++) { - if (!active_uv_only || active_uv_layer == i) - { - if (me->pdata.layers[i].type == CD_MTEXPOLY) { - MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; - MPoly *mpoly = me->mpoly; - for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) { - - Material *mat = give_current_material(ob, mpoly->mat_nr + 1); - if (mat != ma) - continue; - - Image *ima = txface->tpage; - if (ima == NULL) - continue; - - - bool not_in_list = uv_textures.find(ima)==uv_textures.end(); - if (not_in_list) { - std::string name = id_name(ima); - std::string key(name); - key = translate_id(key); - - // create only one <sampler>/<surface> pair for each unique image - if (im_samp_map.find(key) == im_samp_map.end()) { - //<newparam> <sampler> <source> - COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D, - key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX, - key + COLLADASW::Sampler::SURFACE_SID_SUFFIX); - sampler.setImageId(key); - samplers[a] = sampler; - samp_surf[b] = &samplers[a]; - im_samp_map[key] = b; - b++; - a++; - uv_textures.insert(ima); - } - } - } - } - } - } - } - // used as fallback when MTex->uvname is "" (this is pretty common) // it is indeed the correct value to use in that case std::string active_uv(getActiveUVLayerName(ob)); @@ -385,19 +333,6 @@ void EffectsExporter::operator()(Material *ma, Object *ob) writeTextures(ep, key, sampler, t, ima, uvname); } - std::set<Image *>::iterator uv_t_iter; - int idx; - for (idx = 0, uv_t_iter = uv_textures.begin(); uv_t_iter != uv_textures.end(); uv_t_iter++, idx++ ) { - if (active_uv_layer>-1 && idx==active_uv_layer) { - Image *ima = *uv_t_iter; - std::string key(id_name(ima)); - key = translate_id(key); - int i = im_samp_map[key]; - COLLADASW::Sampler *sampler = (COLLADASW::Sampler *)samp_surf[i]; - ep.setDiffuse(createTexture(ima, active_uv, sampler), false, "diffuse"); - } - } - // performs the actual writing ep.addProfileElements(); bool twoSided = false; diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index de91f68a492..33a7527f383 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -42,7 +42,6 @@ public: bool deform_bones_only; bool active_uv_only; - bool include_uv_textures; bool include_material_textures; bool use_texture_copies; diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index aac41e2e93c..a2ab3ce520b 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -152,44 +152,6 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) } } -void ImagesExporter::export_UV_Images() -{ - std::set<Image *> uv_textures; - LinkNode *node; - bool use_texture_copies = this->export_settings->use_texture_copies; - bool active_uv_only = this->export_settings->active_uv_only; - - for (node = this->export_settings->export_set; node; node = node->next) { - Object *ob = (Object *)node->link; - if (ob->type == OB_MESH && ob->totcol) { - Mesh *me = (Mesh *) ob->data; - BKE_mesh_tessface_ensure(me); - int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY); - for (int i = 0; i < me->pdata.totlayer; i++) { - if (me->pdata.layers[i].type == CD_MTEXPOLY) { - if (!active_uv_only || active_uv_layer == i) - { - MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; - for (int j = 0; j < me->totpoly; j++, txface++) { - - Image *ima = txface->tpage; - if (ima == NULL) - continue; - - bool not_in_list = uv_textures.find(ima) == uv_textures.end(); - if (not_in_list) { - uv_textures.insert(ima); - export_UV_Image(ima, use_texture_copies); - } - } - } - } - } - } - } -} - - bool ImagesExporter::hasImages(Scene *sce) { LinkNode *node; @@ -209,20 +171,6 @@ bool ImagesExporter::hasImages(Scene *sce) } } - if (ob->type == OB_MESH) { - Mesh *me = (Mesh *) ob->data; - BKE_mesh_tessface_ensure(me); - bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE); - if (has_uvs) { - int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE); - for (int a = 0; a < num_layers; a++) { - MTFace *tface = (MTFace *)CustomData_get_layer_n(&me->fdata, CD_MTFACE, a); - Image *img = tface->tpage; - if (img) return true; - } - } - } - } return false; } @@ -236,10 +184,6 @@ void ImagesExporter::exportImages(Scene *sce) mf.forEachMaterialInExportSet<ImagesExporter>(sce, *this, this->export_settings->export_set); } - if (this->export_settings->include_uv_textures) { - export_UV_Images(); - } - closeLibrary(); } diff --git a/source/blender/collada/ImageExporter.h b/source/blender/collada/ImageExporter.h index 0eaebdd5cdd..f3dd2b336e4 100644 --- a/source/blender/collada/ImageExporter.h +++ b/source/blender/collada/ImageExporter.h @@ -51,7 +51,6 @@ public: private: std::vector<std::string> mImages; // contains list of written images, to avoid duplicates - void export_UV_Images(); void export_UV_Image(Image *image, bool use_texture_copies); bool hasImages(Scene *sce); const ExportSettings *export_settings; diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index a1bfce88131..616c254a6ea 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -472,11 +472,9 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) COLLADAFW::MeshVertexData::InputInfos *info = collada_mesh->getUVCoords().getInputInfosArray()[i]; COLLADAFW::String &uvname = info->mName; // Allocate space for UV_data - CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, uvname.c_str()); CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, uvname.c_str()); } // activate the first uv map - me->mtpoly = (MTexPoly *)CustomData_get_layer_n(&me->pdata, CD_MTEXPOLY, 0); me->mloopuv = (MLoopUV *) CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, 0); } @@ -1051,11 +1049,11 @@ void MeshImporter::optimize_material_assignements() * which materials shall be moved to the created geometries. Also see * optimize_material_assignements() above. */ -MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmaterial, - std::map<COLLADAFW::UniqueId, Material *>& uid_material_map, - Object *ob, const COLLADAFW::UniqueId *geom_uid, - char *layername, MTFace *texture_face, - std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index) +void MeshImporter::assign_material_to_geom( + COLLADAFW::MaterialBinding cmaterial, + std::map<COLLADAFW::UniqueId, Material *>& uid_material_map, + Object *ob, const COLLADAFW::UniqueId *geom_uid, + std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index) { MTex *color_texture = NULL; Mesh *me = (Mesh *)ob->data; @@ -1065,7 +1063,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri if (uid_material_map.find(ma_uid) == uid_material_map.end()) { fprintf(stderr, "Cannot find material by UID.\n"); - return NULL; + return; } // first time we get geom_uid, ma_uid pair. Save for later check. @@ -1089,15 +1087,6 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri color_texture); } - // set texture face - if (color_texture && - strlen((color_texture)->uvname) && - !STREQ(layername, color_texture->uvname)) { - texture_face = (MTFace *)CustomData_get_layer_named(&me->fdata, CD_MTFACE, - color_texture->uvname); - strcpy(layername, color_texture->uvname); - } - MaterialIdPrimitiveArrayMap& mat_prim_map = geom_uid_mat_mapping_map[*geom_uid]; COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId(); @@ -1114,15 +1103,9 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri for (i = 0; i < prim.totpoly; i++, mpoly++) { mpoly->mat_nr = mat_index; - // bind texture images to faces - if (texture_face && color_texture) { - texture_face->tpage = (Image *)color_texture->tex->ima; - texture_face++; - } } } } - return texture_face; } Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, @@ -1175,10 +1158,6 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta if (old_mesh->id.us == 0) BKE_libblock_free(G.main, old_mesh); - char layername[100]; - layername[0] = '\0'; - MTFace *texture_face = NULL; - COLLADAFW::MaterialBindingArray& mat_array = geom->getMaterialBindings(); @@ -1186,9 +1165,9 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta for (unsigned int i = 0; i < mat_array.getCount(); i++) { if (mat_array[i].getReferencedMaterial().isValid()) { - texture_face = assign_material_to_geom(mat_array[i], uid_material_map, ob, geom_uid, - layername, texture_face, - material_texture_mapping_map, i); + assign_material_to_geom( + mat_array[i], uid_material_map, ob, geom_uid, + material_texture_mapping_map, i); } else { fprintf(stderr, "invalid referenced material for %s\n", mat_array[i].getName().c_str()); diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index d6426fbaf56..e8ae934a393 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -171,11 +171,11 @@ public: void optimize_material_assignements(); - MTFace *assign_material_to_geom(COLLADAFW::MaterialBinding cmaterial, - std::map<COLLADAFW::UniqueId, Material*>& uid_material_map, - Object *ob, const COLLADAFW::UniqueId *geom_uid, - char *layername, MTFace *texture_face, - std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index); + void assign_material_to_geom( + COLLADAFW::MaterialBinding cmaterial, + std::map<COLLADAFW::UniqueId, Material*>& uid_material_map, + Object *ob, const COLLADAFW::UniqueId *geom_uid, + std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index); Object *create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index bfe3180909b..9cb0b414721 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -68,6 +68,7 @@ int collada_import(bContext *C, } int collada_export(Scene *sce, + SceneLayer *scene_layer, const char *filepath, int apply_modifiers, @@ -80,7 +81,6 @@ int collada_export(Scene *sce, int deform_bones_only, int active_uv_only, - int include_uv_textures, int include_material_textures, int use_texture_copies, @@ -106,7 +106,6 @@ int collada_export(Scene *sce, export_settings.deform_bones_only = deform_bones_only != 0; export_settings.active_uv_only = active_uv_only != 0; - export_settings.include_uv_textures = include_uv_textures != 0; export_settings.include_material_textures= include_material_textures != 0; export_settings.use_texture_copies = use_texture_copies != 0; @@ -124,7 +123,7 @@ int collada_export(Scene *sce, if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE; eObjectSet objectSet = (export_settings.selected) ? OB_SET_SELECTED : OB_SET_ALL; - export_settings.export_set = BKE_object_relational_superset(sce, objectSet, (eObRelationTypes)includeFilter); + export_settings.export_set = BKE_object_relational_superset(scene_layer, objectSet, (eObRelationTypes)includeFilter); int export_count = BLI_linklist_count(export_settings.export_set); if (export_count == 0) { diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index 8035af59c8b..9aba51ef18a 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -48,6 +48,7 @@ typedef enum BC_export_transformation_type { struct bContext; struct Scene; +struct SceneLayer; /* * both return 1 on success, 0 on error @@ -63,6 +64,7 @@ int collada_import(struct bContext *C, int keep_bind_info); int collada_export(struct Scene *sce, + struct SceneLayer *scene_layer, const char *filepath, int apply_modifiers, BC_export_mesh_type export_mesh_type, @@ -74,7 +76,6 @@ int collada_export(struct Scene *sce, int deform_bones_only, int active_uv_only, - int include_uv_textures, int include_material_textures, int use_texture_copies, diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index ac4395e1430..1ba8658f245 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -45,7 +45,6 @@ extern "C" { #include "BKE_context.h" #include "BKE_customdata.h" -#include "BKE_depsgraph.h" #include "BKE_object.h" #include "BKE_global.h" #include "BKE_mesh.h" @@ -61,6 +60,8 @@ extern "C" { #include "bmesh_tools.h" } +#include "DEG_depsgraph.h" + #include "collada_utils.h" #include "ExportSettings.h" @@ -118,8 +119,8 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) BKE_object_workob_calc_parent(sce, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); - DAG_id_tag_update(&par->id, OB_RECALC_OB); + DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); + DEG_id_tag_update(&par->id, OB_RECALC_OB); /** done once after import */ #if 0 @@ -136,7 +137,7 @@ Object *bc_add_object(Scene *scene, int type, const char *name) ob->data = BKE_object_obdata_add_from_type(G.main, type, name); ob->lay = scene->lay; - DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); + DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); BKE_scene_base_select(scene, BKE_scene_base_add(scene, ob)); |