Merge pull request #12548 from SaracenOne/vertex_compression_import_fix
Restores functionality of the use_compression flag in Collada import
This commit is contained in:
commit
fc6ef93cc8
|
@ -88,10 +88,10 @@ struct ColladaImport {
|
||||||
Error _populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
|
Error _populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
|
||||||
Error _create_scene_skeletons(Collada::Node *p_node);
|
Error _create_scene_skeletons(Collada::Node *p_node);
|
||||||
Error _create_scene(Collada::Node *p_node, Spatial *p_parent);
|
Error _create_scene(Collada::Node *p_node, Spatial *p_parent);
|
||||||
Error _create_resources(Collada::Node *p_node);
|
Error _create_resources(Collada::Node *p_node, bool p_use_compression);
|
||||||
Error _create_material(const String &p_target);
|
Error _create_material(const String &p_target);
|
||||||
Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh> > p_morph_meshes = Vector<Ref<ArrayMesh> >(), bool p_for_morph = false, bool p_use_mesh_material = false);
|
Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh> > p_morph_meshes = Vector<Ref<ArrayMesh> >(), bool p_use_compression = false, bool p_use_mesh_material = false);
|
||||||
Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false);
|
Error load(const String &p_path, int p_flags, bool p_force_make_tangents = false, bool p_use_compression = false);
|
||||||
void _fix_param_animation_tracks();
|
void _fix_param_animation_tracks();
|
||||||
void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
|
void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
|
||||||
void create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
|
void create_animations(bool p_make_tracks_in_all_bones, bool p_import_value_tracks);
|
||||||
|
@ -608,7 +608,7 @@ static void _generate_tangents_and_binormals(const PoolVector<int> &p_indices, c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh> > p_morph_meshes, bool p_for_morph, bool p_use_mesh_material) {
|
Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh> > p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) {
|
||||||
|
|
||||||
bool local_xform_mirror = p_local_xform.basis.determinant() < 0;
|
bool local_xform_mirror = p_local_xform.basis.determinant() < 0;
|
||||||
|
|
||||||
|
@ -1119,7 +1119,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
|
||||||
mr.push_back(a);
|
mr.push_back(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, p_for_morph ? 0 : Mesh::ARRAY_COMPRESS_DEFAULT);
|
p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, p_use_compression ? Mesh::ARRAY_COMPRESS_DEFAULT : 0);
|
||||||
|
|
||||||
if (material.is_valid()) {
|
if (material.is_valid()) {
|
||||||
if (p_use_mesh_material) {
|
if (p_use_mesh_material) {
|
||||||
|
@ -1139,7 +1139,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error ColladaImport::_create_resources(Collada::Node *p_node) {
|
Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compression) {
|
||||||
|
|
||||||
if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) {
|
if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) {
|
||||||
|
|
||||||
|
@ -1309,7 +1309,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
|
||||||
if (collada.state.mesh_data_map.has(meshid)) {
|
if (collada.state.mesh_data_map.has(meshid)) {
|
||||||
Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
|
Ref<ArrayMesh> mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
|
||||||
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
|
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
|
||||||
Error err = _create_mesh_surfaces(false, mesh, ng->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh> >(), true);
|
Error err = _create_mesh_surfaces(false, mesh, ng->material_map, meshdata, apply_xform, bone_remap, skin, NULL, Vector<Ref<ArrayMesh> >(), false);
|
||||||
ERR_FAIL_COND_V(err, err);
|
ERR_FAIL_COND_V(err, err);
|
||||||
|
|
||||||
morphs.push_back(mesh);
|
morphs.push_back(mesh);
|
||||||
|
@ -1345,7 +1345,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
|
||||||
mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
|
mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
|
||||||
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
|
const Collada::MeshData &meshdata = collada.state.mesh_data_map[meshid];
|
||||||
mesh->set_name(meshdata.name);
|
mesh->set_name(meshdata.name);
|
||||||
Error err = _create_mesh_surfaces(morphs.size() == 0, mesh, ng->material_map, meshdata, apply_xform, bone_remap, skin, morph, morphs, false, use_mesh_builtin_materials);
|
Error err = _create_mesh_surfaces(morphs.size() == 0, mesh, ng->material_map, meshdata, apply_xform, bone_remap, skin, morph, morphs, p_use_compression, use_mesh_builtin_materials);
|
||||||
ERR_FAIL_COND_V(err, err);
|
ERR_FAIL_COND_V(err, err);
|
||||||
|
|
||||||
mesh_cache[meshid] = mesh;
|
mesh_cache[meshid] = mesh;
|
||||||
|
@ -1388,14 +1388,14 @@ Error ColladaImport::_create_resources(Collada::Node *p_node) {
|
||||||
|
|
||||||
for (int i = 0; i < p_node->children.size(); i++) {
|
for (int i = 0; i < p_node->children.size(); i++) {
|
||||||
|
|
||||||
Error err = _create_resources(p_node->children[i]);
|
Error err = _create_resources(p_node->children[i], p_use_compression);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_tangents) {
|
Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_tangents, bool p_use_compression) {
|
||||||
|
|
||||||
Error err = collada.load(p_path, p_flags);
|
Error err = collada.load(p_path, p_flags);
|
||||||
ERR_FAIL_COND_V(err, err);
|
ERR_FAIL_COND_V(err, err);
|
||||||
|
@ -1430,7 +1430,7 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t
|
||||||
ERR_FAIL_COND_V(err, err);
|
ERR_FAIL_COND_V(err, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
Error err2 = _create_resources(vs.root_nodes[i]);
|
Error err2 = _create_resources(vs.root_nodes[i], p_use_compression);
|
||||||
if (err2 != OK) {
|
if (err2 != OK) {
|
||||||
memdelete(scene);
|
memdelete(scene);
|
||||||
ERR_FAIL_COND_V(err2, err2);
|
ERR_FAIL_COND_V(err2, err2);
|
||||||
|
@ -1933,7 +1933,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_
|
||||||
state.use_mesh_builtin_materials = !(p_flags & IMPORT_MATERIALS_IN_INSTANCES);
|
state.use_mesh_builtin_materials = !(p_flags & IMPORT_MATERIALS_IN_INSTANCES);
|
||||||
state.bake_fps = p_bake_fps;
|
state.bake_fps = p_bake_fps;
|
||||||
|
|
||||||
Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS);
|
Error err = state.load(p_path, flags, p_flags & EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS, p_flags & EditorSceneImporter::IMPORT_USE_COMPRESSION);
|
||||||
|
|
||||||
ERR_FAIL_COND_V(err != OK, NULL);
|
ERR_FAIL_COND_V(err != OK, NULL);
|
||||||
|
|
||||||
|
|
|
@ -1037,6 +1037,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
|
||||||
if (bool(p_options["animation/import"]))
|
if (bool(p_options["animation/import"]))
|
||||||
import_flags |= EditorSceneImporter::IMPORT_ANIMATION;
|
import_flags |= EditorSceneImporter::IMPORT_ANIMATION;
|
||||||
|
|
||||||
|
if (int(p_options["meshes/compress"]))
|
||||||
|
import_flags |= EditorSceneImporter::IMPORT_USE_COMPRESSION;
|
||||||
|
|
||||||
if (bool(p_options["meshes/ensure_tangents"]))
|
if (bool(p_options["meshes/ensure_tangents"]))
|
||||||
import_flags |= EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
|
import_flags |= EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ public:
|
||||||
IMPORT_ANIMATION_KEEP_VALUE_TRACKS = 32,
|
IMPORT_ANIMATION_KEEP_VALUE_TRACKS = 32,
|
||||||
IMPORT_GENERATE_TANGENT_ARRAYS = 256,
|
IMPORT_GENERATE_TANGENT_ARRAYS = 256,
|
||||||
IMPORT_FAIL_ON_MISSING_DEPENDENCIES = 512,
|
IMPORT_FAIL_ON_MISSING_DEPENDENCIES = 512,
|
||||||
IMPORT_MATERIALS_IN_INSTANCES = 1024
|
IMPORT_MATERIALS_IN_INSTANCES = 1024,
|
||||||
|
IMPORT_USE_COMPRESSION = 2048
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue