Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/collada/collada_utils.cpp')
-rw-r--r--source/blender/collada/collada_utils.cpp65
1 files changed, 15 insertions, 50 deletions
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index d4196bacf0d..3e17472e9c2 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -324,65 +324,30 @@ std::string bc_replace_string(std::string data, const std::string& pattern,
* Calculate a rescale factor such that the imported scene's scale
* is preserved. I.e. 1 meter in the import will also be
* 1 meter in the current scene.
- * XXX : I am not sure if it is correct to map 1 Blender Unit
- * to 1 Meter for unit type NONE. But it looks reasonable to me.
*/
-void bc_match_scale(std::vector<Object *> *objects_done,
- Scene &sce,
- UnitConverter &bc_unit)
-{
- Object *ob = NULL;
-
- PointerRNA scene_ptr, unit_settings;
- PropertyRNA *system_ptr, *scale_ptr;
- RNA_id_pointer_create(&sce.id, &scene_ptr);
-
- unit_settings = RNA_pointer_get(&scene_ptr, "unit_settings");
- system_ptr = RNA_struct_find_property(&unit_settings, "system");
- scale_ptr = RNA_struct_find_property(&unit_settings, "scale_length");
-
- int type = RNA_property_enum_get(&unit_settings, system_ptr);
- float bl_scale;
-
- switch (type) {
- case USER_UNIT_NONE:
- bl_scale = 1.0; // map 1 Blender unit to 1 Meter
- break;
-
- case USER_UNIT_METRIC:
- bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
- break;
-
- default :
- bl_scale = RNA_property_float_get(&unit_settings, scale_ptr);
- // it looks like the conversion to Imperial is done implicitly.
- // So nothing to do here.
- break;
+void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene)
+{
+ if (scale_to_scene) {
+ mul_m4_m4m4(ob->obmat, bc_unit.get_scale(), ob->obmat);
}
-
- float scale_conv = bc_unit.getLinearMeter() / bl_scale;
-
- float rescale[3];
- rescale[0] = rescale[1] = rescale[2] = scale_conv;
-
- float size_mat4[4][4];
-
- float axis_mat4[4][4];
- unit_m4(axis_mat4);
-
- size_to_mat4(size_mat4, rescale);
+ mul_m4_m4m4(ob->obmat, bc_unit.get_rotation(), ob->obmat);
+ BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
+}
+void bc_match_scale(std::vector<Object *> *objects_done,
+ UnitConverter &bc_unit,
+ bool scale_to_scene)
+{
for (std::vector<Object *>::iterator it = objects_done->begin();
it != objects_done->end();
++it)
{
- ob = *it;
- mul_m4_m4m4(ob->obmat, size_mat4, ob->obmat);
- mul_m4_m4m4(ob->obmat, bc_unit.get_rotation(), ob->obmat);
- BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
+ Object *ob = *it;
+ if (ob -> parent == NULL) {
+ bc_match_scale(*it, bc_unit, scale_to_scene);
+ }
}
-
}
void bc_triangulate_mesh(Mesh *me)