diff options
Diffstat (limited to 'modules/fbx')
| -rw-r--r-- | modules/fbx/data/fbx_material.cpp | 20 | ||||
| -rw-r--r-- | modules/fbx/data/fbx_mesh_data.cpp | 14 | ||||
| -rw-r--r-- | modules/fbx/data/fbx_mesh_data.h | 2 | ||||
| -rw-r--r-- | modules/fbx/data/import_state.h | 1 | ||||
| -rw-r--r-- | modules/fbx/editor_scene_importer_fbx.cpp | 26 | ||||
| -rw-r--r-- | modules/fbx/editor_scene_importer_fbx.h | 1 | ||||
| -rw-r--r-- | modules/fbx/fbx_parser/ByteSwapper.h | 2 | ||||
| -rw-r--r-- | modules/fbx/fbx_parser/FBXDocument.cpp | 2 | ||||
| -rw-r--r-- | modules/fbx/fbx_parser/FBXParser.cpp | 4 | ||||
| -rw-r--r-- | modules/fbx/register_types.cpp | 4 | ||||
| -rw-r--r-- | modules/fbx/tools/import_utils.h | 10 | ||||
| -rw-r--r-- | modules/fbx/tools/validation_tools.h | 3 | 
12 files changed, 45 insertions, 44 deletions
| diff --git a/modules/fbx/data/fbx_material.cpp b/modules/fbx/data/fbx_material.cpp index d54ac86e9f..86baec4244 100644 --- a/modules/fbx/data/fbx_material.cpp +++ b/modules/fbx/data/fbx_material.cpp @@ -29,6 +29,10 @@  /*************************************************************************/  #include "fbx_material.h" + +// FIXME: Shouldn't depend on core_bind.h! Use DirAccessRef like the rest of +// the engine instead of core_bind::Directory. +#include "core/core_bind.h"  #include "scene/resources/material.h"  #include "scene/resources/texture.h"  #include "tools/validation_tools.h" @@ -51,7 +55,7 @@ void FBXMaterial::add_search_string(String p_filename, String p_current_director  }  String find_file(const String &p_base, const String &p_file_to_find) { -	_Directory dir; +	core_bind::Directory dir;  	dir.open(p_base);  	dir.list_dir_begin(); @@ -80,7 +84,7 @@ String find_file(const String &p_base, const String &p_file_to_find) {  // fbx will not give us good path information and let's not regex them to fix them  // no relative paths are in fbx generally they have a rel field but it's populated incorrectly by the SDK.  String FBXMaterial::find_texture_path_by_filename(const String p_filename, const String p_current_directory) { -	_Directory dir; +	core_bind::Directory dir;  	Vector<String> paths;  	add_search_string(p_filename, p_current_directory, "", paths);  	add_search_string(p_filename, p_current_directory, "texture", paths); @@ -160,7 +164,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {  	const String p_fbx_current_directory = state.path;  	Ref<StandardMaterial3D> spatial_material; -	spatial_material.instance(); +	spatial_material.instantiate();  	// read the material file  	// is material two sided @@ -223,7 +227,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {  			} else if (fbx_texture_data != nullptr && fbx_texture_data->Media() != nullptr && fbx_texture_data->Media()->IsEmbedded()) {  				// This is an embedded texture. Extract it.  				Ref<Image> image; -				//image.instance(); // oooo double instance bug? why make Image::_png_blah call +				//image.instantiate(); // oooo double instance bug? why make Image::_png_blah call  				const String extension = texture_name.get_extension().to_upper();  				if (extension == "PNG") { @@ -256,7 +260,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {  				}  				Ref<ImageTexture> image_texture; -				image_texture.instance(); +				image_texture.instantiate();  				image_texture->create_from_image(image);  				texture = image_texture; @@ -324,7 +328,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {  		if (spatial_material.is_null()) {  			// Done here so if no data no material is created. -			spatial_material.instance(); +			spatial_material.instantiate();  		}  		const FBXDocParser::TypedProperty<real_t> *real_value = dynamic_cast<const FBXDocParser::TypedProperty<real_t> *>(prop); @@ -420,7 +424,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {  			} break;  			case PROPERTY_DESC_COAT_ROUGHNESS: {  				// meaning is that approx equal to zero is disabled not actually zero. ;) -				if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) { +				if (real_value && Math::is_zero_approx(real_value->Value())) {  					print_verbose("clearcoat real value: " + rtos(real_value->Value()));  					spatial_material->set_clearcoat_gloss(1.0 - real_value->Value());  				} else { @@ -428,7 +432,7 @@ Ref<StandardMaterial3D> FBXMaterial::import_material(ImportState &state) {  				}  			} break;  			case PROPERTY_DESC_EMISSIVE: { -				if (real_value && Math::is_equal_approx(real_value->Value(), 0.0f)) { +				if (real_value && Math::is_zero_approx(real_value->Value())) {  					print_verbose("Emissive real value: " + rtos(real_value->Value()));  					spatial_material->set_emission_energy(real_value->Value());  				} else if (vector_value && !vector_value->Value().is_equal_approx(Vector3(0, 0, 0))) { diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 8f32c523f9..dcea476275 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -211,7 +211,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s  			const int surface_id = polygon_surfaces[*polygon_id];  			if (surfaces.has(surface_id) == false) {  				SurfaceData sd; -				sd.surface_tool.instance(); +				sd.surface_tool.instantiate();  				sd.surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);  				if (surface_id < 0) { @@ -316,7 +316,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s  			Vector3 *normals_ptr = morph_data->normals.ptrw();  			Ref<SurfaceTool> morph_st; -			morph_st.instance(); +			morph_st.instantiate();  			morph_st->begin(Mesh::PRIMITIVE_TRIANGLES);  			for (unsigned int vi = 0; vi < surface->vertices_map.size(); vi += 1) { @@ -345,7 +345,7 @@ EditorSceneImporterMeshNode3D *FBXMeshData::create_fbx_mesh(const ImportState &s  	// Phase 6. Compose the mesh and return it.  	Ref<EditorSceneImporterMesh> mesh; -	mesh.instance(); +	mesh.instantiate();  	// Add blend shape info.  	for (const String *morph_name = morphs.next(nullptr); morph_name != nullptr; morph_name = morphs.next(morph_name)) { @@ -433,7 +433,7 @@ void FBXMeshData::sanitize_vertex_weights(const ImportState &state) {  		{  			// Sort -			real_t *weights_ptr = vm->weights.ptrw(); +			float *weights_ptr = vm->weights.ptrw();  			int *bones_ptr = vm->bones.ptrw();  			for (int i = 0; i < vm->weights.size(); i += 1) {  				for (int x = i + 1; x < vm->weights.size(); x += 1) { @@ -449,7 +449,7 @@ void FBXMeshData::sanitize_vertex_weights(const ImportState &state) {  			// Resize  			vm->weights.resize(max_vertex_influence_count);  			vm->bones.resize(max_vertex_influence_count); -			real_t *weights_ptr = vm->weights.ptrw(); +			float *weights_ptr = vm->weights.ptrw();  			int *bones_ptr = vm->bones.ptrw();  			for (int i = initial_size; i < max_vertex_influence_count; i += 1) {  				weights_ptr[i] = 0.0; @@ -525,7 +525,7 @@ void FBXMeshData::reorganize_vertices(  				}  				const Vector3 vert_poly_normal = *nrml_arr->getptr(*pid); -				if ((this_vert_poly_normal - vert_poly_normal).length_squared() > CMP_EPSILON) { +				if (!vert_poly_normal.is_equal_approx(this_vert_poly_normal)) {  					// Yes this polygon need duplication.  					need_duplication = true;  					break; @@ -586,7 +586,7 @@ void FBXMeshData::reorganize_vertices(  								continue;  							}  							const Vector2 vert_poly_uv = *uvs->getptr(*pid); -							if (((*this_vert_poly_uv) - vert_poly_uv).length_squared() > CMP_EPSILON) { +							if (!vert_poly_uv.is_equal_approx(*this_vert_poly_uv)) {  								// Yes this polygon need duplication.  								need_duplication = true;  								break; diff --git a/modules/fbx/data/fbx_mesh_data.h b/modules/fbx/data/fbx_mesh_data.h index 7486c5c59c..24db4a5469 100644 --- a/modules/fbx/data/fbx_mesh_data.h +++ b/modules/fbx/data/fbx_mesh_data.h @@ -64,7 +64,7 @@ struct SurfaceData {  };  struct VertexWeightMapping { -	Vector<real_t> weights; +	Vector<float> weights;  	Vector<int> bones;  	// This extra vector is used because the bone id is computed in a second step.  	// TODO Get rid of this extra step is a good idea. diff --git a/modules/fbx/data/import_state.h b/modules/fbx/data/import_state.h index 83bc43faff..9ba60eaacf 100644 --- a/modules/fbx/data/import_state.h +++ b/modules/fbx/data/import_state.h @@ -37,7 +37,6 @@  #include "pivot_transform.h" -#include "core/core_bind.h"  #include "core/io/resource_importer.h"  #include "core/templates/vector.h"  #include "editor/import/resource_importer_scene.h" diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index 40deaae74d..e3f36ef3e3 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -373,7 +373,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  	scene_root->add_child(state.root);  	state.root->set_owner(scene_root); -	state.fbx_root_node.instance(); +	state.fbx_root_node.instantiate();  	state.fbx_root_node->godot_node = state.root;  	// Size relative to cm. @@ -389,11 +389,11 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  	// Enabled by default.  	state.enable_animation_import = true;  	Ref<FBXNode> root_node; -	root_node.instance(); +	root_node.instantiate();  	// make sure fake noFBXDocParser::PropertyPtr ptrde always has a transform too ;)  	Ref<PivotTransform> pivot_transform; -	pivot_transform.instance(); +	pivot_transform.instantiate();  	root_node->pivot_transform = pivot_transform;  	root_node->node_name = "root node";  	root_node->current_node_id = 0; @@ -479,7 +479,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  			if (state.renderer_mesh_data.has(mesh_id)) {  				mesh_vertex_data = state.renderer_mesh_data[mesh_id];  			} else { -				mesh_vertex_data.instance(); +				mesh_vertex_data.instantiate();  				state.renderer_mesh_data.insert(mesh_id, mesh_vertex_data);  			} @@ -535,7 +535,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  			ERR_CONTINUE_MSG(!mat, "Could not convert fbx material by id: " + itos(material_id));  			Ref<FBXMaterial> material; -			material.instance(); +			material.instantiate();  			material->set_imported_material(mat);  			Ref<StandardMaterial3D> godot_material = material->import_material(state); @@ -575,7 +575,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  			if (state.skeleton_map.has(armature_id)) {  				fbx_skeleton_inst = state.skeleton_map[armature_id];  			} else { -				fbx_skeleton_inst.instance(); +				fbx_skeleton_inst.instantiate();  				state.skeleton_map.insert(armature_id, fbx_skeleton_inst);  			} @@ -650,7 +650,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  						if (state.renderer_mesh_data.has(mesh_id)) {  							mesh_data_precached = state.renderer_mesh_data[mesh_id];  						} else { -							mesh_data_precached.instance(); +							mesh_data_precached.instantiate();  							state.renderer_mesh_data.insert(mesh_id, mesh_data_precached);  						} @@ -735,7 +735,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  		Ref<Skin> skin;  		if (!state.MeshSkins.has(mesh_id)) {  			print_verbose("Created new skin"); -			skin.instance(); +			skin.instantiate();  			state.MeshSkins.insert(mesh_id, skin);  		} else {  			print_verbose("Grabbed skin"); @@ -848,7 +848,7 @@ Node3D *EditorSceneImporterFBX::_generate_scene(  				}  				Ref<Animation> animation; -				animation.instance(); +				animation.instantiate();  				animation->set_name(animation_name);  				animation->set_length(duration); @@ -1312,7 +1312,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,  		// declare our bone element reference (invalid, unless we create a bone in this step)  		// this lets us pass valid armature information into children objects and this is why we moved this up here -		// previously this was created .instanced() on the same line. +		// previously this was created .instantiated() on the same line.  		Ref<FBXBone> bone_element;  		if (model != nullptr) { @@ -1324,7 +1324,7 @@ void EditorSceneImporterFBX::BuildDocumentBones(Ref<FBXBone> p_parent_bone,  				ERR_FAIL_COND_MSG(state.fbx_bone_map.has(limb_node->ID()), "[serious] duplicate LimbNode detected");  				bool parent_is_bone = state.fbx_bone_map.find(p_id); -				bone_element.instance(); +				bone_element.instantiate();  				// used to build the bone hierarchy in the skeleton  				bone_element->parent_bone_id = parent_is_bone ? p_id : 0; @@ -1404,12 +1404,12 @@ void EditorSceneImporterFBX::BuildDocumentNodes(  			uint64_t current_node_id = model->ID();  			Ref<FBXNode> new_node; -			new_node.instance(); +			new_node.instantiate();  			new_node->current_node_id = current_node_id;  			new_node->node_name = ImportUtils::FBXNodeToName(model->Name());  			Ref<PivotTransform> fbx_transform; -			fbx_transform.instance(); +			fbx_transform.instantiate();  			fbx_transform->set_parent(parent_transform);  			fbx_transform->set_model(model);  			fbx_transform->debug_pivot_xform("name: " + new_node->node_name); diff --git a/modules/fbx/editor_scene_importer_fbx.h b/modules/fbx/editor_scene_importer_fbx.h index 4bb2c9d21b..4a3b78480b 100644 --- a/modules/fbx/editor_scene_importer_fbx.h +++ b/modules/fbx/editor_scene_importer_fbx.h @@ -36,7 +36,6 @@  #include "data/import_state.h"  #include "tools/import_utils.h" -#include "core/core_bind.h"  #include "core/io/resource_importer.h"  #include "core/string/ustring.h"  #include "core/templates/local_vector.h" diff --git a/modules/fbx/fbx_parser/ByteSwapper.h b/modules/fbx/fbx_parser/ByteSwapper.h index 5c16383974..08d38147d5 100644 --- a/modules/fbx/fbx_parser/ByteSwapper.h +++ b/modules/fbx/fbx_parser/ByteSwapper.h @@ -70,7 +70,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  ----------------------------------------------------------------------  */ -/** @file Helper class tp perform various byte oder swappings +/** @file Helper class tp perform various byte order swappings     (e.g. little to big endian) */  #ifndef BYTE_SWAPPER_H  #define BYTE_SWAPPER_H diff --git a/modules/fbx/fbx_parser/FBXDocument.cpp b/modules/fbx/fbx_parser/FBXDocument.cpp index 89c69d2ee8..92c62e68b5 100644 --- a/modules/fbx/fbx_parser/FBXDocument.cpp +++ b/modules/fbx/fbx_parser/FBXDocument.cpp @@ -198,7 +198,7 @@ ObjectPtr LazyObject::LoadObject() {  			object.reset(new ModelLimbNode(id, element, doc, name));  		} else if (strcmp(classtag.c_str(), "IKEffector") && strcmp(classtag.c_str(), "FKEffector")) { -			// FK and IK effectors are not supporte +			// FK and IK effectors are not supported.  			object.reset(new Model(id, element, doc, name));  		}  	} else if (!strncmp(obtype, "Material", length)) { diff --git a/modules/fbx/fbx_parser/FBXParser.cpp b/modules/fbx/fbx_parser/FBXParser.cpp index 163518d18f..d9ef025a16 100644 --- a/modules/fbx/fbx_parser/FBXParser.cpp +++ b/modules/fbx/fbx_parser/FBXParser.cpp @@ -575,7 +575,7 @@ void ReadBinaryDataArray(char type, uint32_t count, const char *&data, const cha  		std::copy(data, end, buff.begin());  	} else if (encmode == 1) {  		// zlib/deflate, next comes ZIP head (0x78 0x01) -		// see http://www.ietf.org/rfc/rfc1950.txt +		// see https://www.ietf.org/rfc/rfc1950.txt  		z_stream zstream;  		zstream.opaque = Z_NULL; @@ -1167,7 +1167,7 @@ Transform3D ReadMatrix(const ElementPtr element) {  	// clean values to prevent any IBM damage on inverse() / affine_inverse()  	for (float &value : values) { -		if (::Math::is_equal_approx(0, value)) { +		if (::Math::is_zero_approx(value)) {  			value = 0;  		}  	} diff --git a/modules/fbx/register_types.cpp b/modules/fbx/register_types.cpp index c0591dbc77..a75da8f3a9 100644 --- a/modules/fbx/register_types.cpp +++ b/modules/fbx/register_types.cpp @@ -36,7 +36,7 @@  #ifdef TOOLS_ENABLED  static void _editor_init() {  	Ref<EditorSceneImporterFBX> import_fbx; -	import_fbx.instance(); +	import_fbx.instantiate();  	ResourceImporterScene::get_singleton()->add_importer(import_fbx);  }  #endif @@ -46,7 +46,7 @@ void register_fbx_types() {  	ClassDB::APIType prev_api = ClassDB::get_current_api();  	ClassDB::set_current_api(ClassDB::API_EDITOR); -	ClassDB::register_class<EditorSceneImporterFBX>(); +	GDREGISTER_CLASS(EditorSceneImporterFBX);  	ClassDB::set_current_api(prev_api); diff --git a/modules/fbx/tools/import_utils.h b/modules/fbx/tools/import_utils.h index 7625f67256..fbe7dbd82f 100644 --- a/modules/fbx/tools/import_utils.h +++ b/modules/fbx/tools/import_utils.h @@ -137,15 +137,15 @@ public:  	static Vector3 safe_import_vector3(const Vector3 &p_vec) {  		Vector3 vector = p_vec; -		if (Math::is_equal_approx(0, vector.x)) { +		if (Math::is_zero_approx(vector.x)) {  			vector.x = 0;  		} -		if (Math::is_equal_approx(0, vector.y)) { +		if (Math::is_zero_approx(vector.y)) {  			vector.y = 0;  		} -		if (Math::is_equal_approx(0, vector.z)) { +		if (Math::is_zero_approx(vector.z)) {  			vector.z = 0;  		}  		return vector; @@ -317,7 +317,7 @@ public:  	// 		}  	// 	} else {  	// 		Ref<Image> img; -	// 		img.instance(); +	// 		img.instantiate();  	// 		PoolByteArray arr;  	// 		uint32_t size = tex->mWidth * tex->mHeight;  	// 		arr.resize(size); @@ -362,7 +362,7 @@ public:  	// 	if (found) {  	// 		image_state.raw_image = AssimpUtils::load_image(state, state.assimp_scene, path);  	// 		if (image_state.raw_image.is_valid()) { -	// 			image_state.texture.instance(); +	// 			image_state.texture.instantiate();  	// 			image_state.texture->create_from_image(image_state.raw_image);  	// 			image_state.texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY);  	// 			return true; diff --git a/modules/fbx/tools/validation_tools.h b/modules/fbx/tools/validation_tools.h index 6c15eb7e12..906a721045 100644 --- a/modules/fbx/tools/validation_tools.h +++ b/modules/fbx/tools/validation_tools.h @@ -34,8 +34,7 @@  #ifdef TOOLS_ENABLED  #include "core/io/file_access.h" -#include "core/io/json.h" -#include "core/string/ustring.h" +#include "core/string/print_string.h"  #include "core/templates/local_vector.h"  #include "core/templates/map.h" |