diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2020-10-17 01:08:21 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2021-06-03 07:30:01 -0400 |
commit | de3f6699a5192153e9882a62b58b9ca6cd82ee2d (patch) | |
tree | 7cee99845cc6bf2db8a48f7776efb046c7990a67 /editor | |
parent | b80494e6331bdfbfd3c754aa225fa2a5105fb917 (diff) |
Rename Transform to Transform3D in core
Diffstat (limited to 'editor')
32 files changed, 244 insertions, 245 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 3620fda4f8..2d688bb37a 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -3459,7 +3459,7 @@ void AnimationTrackEditor::_insert_delay(bool p_create_reset, bool p_create_bezi insert_queue = false; } -void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) { +void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform3D &p_xform) { if (!keying) { return; } @@ -3946,7 +3946,7 @@ AnimationTrackEditor::TrackIndices AnimationTrackEditor::_confirm_insert(InsertD } break; case Animation::TYPE_TRANSFORM: { - Transform tr = p_id.value; + Transform3D tr = p_id.value; Dictionary d; d["location"] = tr.origin; d["scale"] = tr.basis.get_scale(); @@ -4560,7 +4560,7 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) { return; } - Transform xf = base->get_transform(); + Transform3D xf = base->get_transform(); Vector3 loc = xf.get_origin(); Vector3 scale = xf.basis.get_scale_local(); diff --git a/editor/animation_track_editor.h b/editor/animation_track_editor.h index 8befc830fa..756eb4acb6 100644 --- a/editor/animation_track_editor.h +++ b/editor/animation_track_editor.h @@ -526,7 +526,7 @@ public: void set_anim_pos(float p_pos); void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false); void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance); - void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform); + void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform3D &p_xform); void show_select_node_warning(bool p_show); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index de2be710c5..fcd937e72c 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -213,7 +213,7 @@ void ConnectDialog::_add_bind() { value = Basis(); break; case Variant::TRANSFORM: - value = Transform(); + value = Transform3D(); break; case Variant::COLOR: value = Color(); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index c5097a17a5..a12bf036bc 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -60,7 +60,7 @@ Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_ return ret; } -Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) { +Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size) { int size = p_preview_size; RID scenario = RS::get_singleton()->scenario_create(); @@ -94,7 +94,7 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh continue; } - Transform mesh_xform; + Transform3D mesh_xform; if (p_transforms != nullptr) { mesh_xform = (*p_transforms)[i]; } @@ -105,7 +105,7 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; - Transform xform; + Transform3D xform; xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6); xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis; AABB rot_aabb = xform.xform(aabb); @@ -119,11 +119,11 @@ Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh xform.invert(); xform = mesh_xform * xform; - RS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_transform(camera, xform * Transform3D(Basis(), Vector3(0, 0, 3))); RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0); - RS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); - RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance, xform * Transform3D().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform3D().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0))); ep.step(TTR("Thumbnail..."), i); Main::iteration(); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 3f72e468b2..2e1dd0a0c1 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -113,7 +113,7 @@ public: Error save_scene(); void save_scene_as(const String &p_scene, bool p_with_preview = true); - Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform> *p_transforms, int p_preview_size); + Vector<Ref<Texture2D>> make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size); void set_main_screen_editor(const String &p_name); void set_distraction_free_mode(bool p_enter); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 7beff4147d..66180b8653 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2083,7 +2083,7 @@ void EditorPropertyTransform::_value_changed(double val, const String &p_name) { return; } - Transform p; + Transform3D p; p.basis[0][0] = spin[0]->get_value(); p.basis[1][0] = spin[1]->get_value(); p.basis[2][0] = spin[2]->get_value(); @@ -2104,7 +2104,7 @@ void EditorPropertyTransform::update_property() { update_using_transform(get_edited_object()->get(get_edited_property())); } -void EditorPropertyTransform::update_using_transform(Transform p_transform) { +void EditorPropertyTransform::update_using_transform(Transform3D p_transform) { setting = true; spin[0]->set_value(p_transform.basis[0][0]); spin[1]->set_value(p_transform.basis[1][0]); diff --git a/editor/editor_properties.h b/editor/editor_properties.h index 07f496f54d..a254740096 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -541,7 +541,7 @@ protected: public: virtual void update_property() override; - virtual void update_using_transform(Transform p_transform); + virtual void update_using_transform(Transform3D p_transform); void setup(double p_min, double p_max, double p_step, bool p_no_slider); EditorPropertyTransform(); }; diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index e38034dd8c..aa9700716d 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -50,8 +50,8 @@ String Collada::Effect::get_texture_path(const String &p_source, Collada &state) return state.state.image_map[image].path; } -Transform Collada::get_root_transform() const { - Transform unit_scale_transform; +Transform3D Collada::get_root_transform() const { + Transform3D unit_scale_transform; #ifndef COLLADA_IMPORT_SCALE_SCENE unit_scale_transform.scale(Vector3(state.unit_scale, state.unit_scale, state.unit_scale)); #endif @@ -74,8 +74,8 @@ static String _uri_to_id(const String &p_uri) { /** HELPER FUNCTIONS **/ -Transform Collada::fix_transform(const Transform &p_transform) { - Transform tr = p_transform; +Transform3D Collada::fix_transform(const Transform3D &p_transform) { + Transform3D tr = p_transform; #ifndef NO_UP_AXIS_SWAP @@ -102,8 +102,8 @@ Transform Collada::fix_transform(const Transform &p_transform) { //return state.matrix_fix * p_transform; } -static Transform _read_transform_from_array(const Vector<float> &array, int ofs = 0) { - Transform tr; +static Transform3D _read_transform_from_array(const Vector<float> &array, int ofs = 0) { + Transform3D tr; // i wonder why collada matrices are transposed, given that's opposed to opengl.. tr.basis.elements[0][0] = array[0 + ofs]; tr.basis.elements[0][1] = array[1 + ofs]; @@ -122,11 +122,11 @@ static Transform _read_transform_from_array(const Vector<float> &array, int ofs /* STRUCTURES */ -Transform Collada::Node::compute_transform(Collada &state) const { - Transform xform; +Transform3D Collada::Node::compute_transform(Collada &state) const { + Transform3D xform; for (int i = 0; i < xform_list.size(); i++) { - Transform xform_step; + Transform3D xform_step; const XForm &xf = xform_list[i]; switch (xf.op) { case XForm::OP_ROTATE: { @@ -165,11 +165,11 @@ Transform Collada::Node::compute_transform(Collada &state) const { return xform; } -Transform Collada::Node::get_transform() const { +Transform3D Collada::Node::get_transform() const { return default_transform; } -Transform Collada::Node::get_global_transform() const { +Transform3D Collada::Node::get_global_transform() const { if (parent) { return parent->get_global_transform() * default_transform; } else { @@ -201,14 +201,14 @@ Vector<float> Collada::AnimationTrack::get_value_at_time(float p_time) const { if (keys[i].data.size() == 16) { //interpolate a matrix - Transform src = _read_transform_from_array(keys[i - 1].data); - Transform dst = _read_transform_from_array(keys[i].data); + Transform3D src = _read_transform_from_array(keys[i - 1].data); + Transform3D dst = _read_transform_from_array(keys[i].data); - Transform interp = c < 0.001 ? src : src.interpolate_with(dst, c); + Transform3D interp = c < 0.001 ? src : src.interpolate_with(dst, c); Vector<float> ret; ret.resize(16); - Transform tr; + Transform3D tr; // i wonder why collada matrices are transposed, given that's opposed to opengl.. ret.write[0] = interp.basis.elements[0][0]; ret.write[1] = interp.basis.elements[0][1]; @@ -410,10 +410,9 @@ Vector<String> Collada::_read_string_array(XMLParser &parser) { return array; } -Transform Collada::_read_transform(XMLParser &parser) { - if (parser.is_empty()) { - return Transform(); - } +Transform3D Collada::_read_transform(XMLParser &parser) { + if (parser.is_empty()) + return Transform3D(); Vector<String> array; while (parser.read() == OK) { @@ -429,7 +428,7 @@ Transform Collada::_read_transform(XMLParser &parser) { } } - ERR_FAIL_COND_V(array.size() != 16, Transform()); + ERR_FAIL_COND_V(array.size() != 16, Transform3D()); Vector<float> farr; farr.resize(16); for (int i = 0; i < 16; i++) { @@ -1197,7 +1196,7 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { /* STORE REST MATRICES */ - Vector<Transform> rests; + Vector<Transform3D> rests; ERR_FAIL_COND(!skindata.joints.sources.has("JOINT")); ERR_FAIL_COND(!skindata.joints.sources.has("INV_BIND_MATRIX")); @@ -1214,7 +1213,7 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { for (int i = 0; i < joint_source.sarray.size(); i++) { String name = joint_source.sarray[i]; - Transform xform = _read_transform_from_array(ibm_source.array, i * 16); //<- this is a mistake, it must be applied to vertices + Transform3D xform = _read_transform_from_array(ibm_source.array, i * 16); //<- this is a mistake, it must be applied to vertices xform.affine_invert(); // inverse for rest, because it's an inverse #ifdef COLLADA_IMPORT_SCALE_SCENE xform.origin *= state.unit_scale; @@ -2096,7 +2095,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) { NodeSkeleton *skeleton = nullptr; - for (Map<String, Transform>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) { + for (Map<String, Transform3D>::Element *F = cd.bone_rest_map.front(); F; F = F->next()) { String name; if (!state.sid_to_node_map.has(F->key())) { @@ -2240,11 +2239,11 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L //this should be correct ERR_FAIL_COND_V(!state.skin_controller_data_map.has(ng->source), false); SkinControllerData &skin = state.skin_controller_data_map[ng->source]; - Transform skel_inv = sk->get_global_transform().affine_inverse(); + Transform3D skel_inv = sk->get_global_transform().affine_inverse(); p_node->default_transform = skel_inv * (skin.bind_shape /* p_node->get_global_transform()*/); // i honestly have no idea what to do with a previous model xform.. most exporters ignore it //make rests relative to the skeleton (they seem to be always relative to world) - for (Map<String, Transform>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) { + for (Map<String, Transform3D>::Element *E = skin.bone_rest_map.front(); E; E = E->next()) { E->get() = skel_inv * E->get(); //make the bone rest local to the skeleton state.bone_rest_map[E->key()] = E->get(); // make it remember where the bone is globally, now that it's relative } @@ -2252,7 +2251,7 @@ bool Collada::_move_geometry_to_skeletons(VisualScene *p_vscene, Node *p_node, L //but most exporters seem to work only if i do this.. //p_node->default_transform = p_node->get_global_transform(); - //p_node->default_transform=Transform(); //this seems to be correct, because bind shape makes the object local to the skeleton + //p_node->default_transform=Transform3D(); //this seems to be correct, because bind shape makes the object local to the skeleton p_node->ignore_anim = true; // collada may animate this later, if it does, then this is not supported (redo your original asset and don't animate the base mesh) p_node->parent = sk; //sk->children.push_back(0,p_node); //avoid INFINITE loop diff --git a/editor/import/collada.h b/editor/import/collada.h index 2c3f0a3006..5e38637504 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -182,7 +182,7 @@ public: String base; bool use_idrefs = false; - Transform bind_shape; + Transform3D bind_shape; struct Source { Vector<String> sarray; //maybe for names @@ -210,7 +210,7 @@ public: int count = 0; } weights; - Map<String, Transform> bone_rest_map; + Map<String, Transform3D> bone_rest_map; SkinControllerData() {} }; @@ -342,15 +342,15 @@ public: String empty_draw_type; bool noname = false; Vector<XForm> xform_list; - Transform default_transform; - Transform post_transform; + Transform3D default_transform; + Transform3D post_transform; Vector<Node *> children; Node *parent = nullptr; - Transform compute_transform(Collada &state) const; - Transform get_global_transform() const; - Transform get_transform() const; + Transform3D compute_transform(Collada &state) const; + Transform3D get_global_transform() const; + Transform3D get_transform() const; bool ignore_anim = false; @@ -497,7 +497,7 @@ public: Map<String, String> sid_to_node_map; //Map<String,NodeJoint*> bone_map; - Map<String, Transform> bone_rest_map; + Map<String, Transform3D> bone_rest_map; String local_path; String root_visual_scene; @@ -517,9 +517,9 @@ public: Collada(); - Transform fix_transform(const Transform &p_transform); + Transform3D fix_transform(const Transform3D &p_transform); - Transform get_root_transform() const; + Transform3D get_root_transform() const; int get_uv_channel(String p_name); @@ -557,7 +557,7 @@ private: // private stuff Variant _parse_param(XMLParser &parser); Vector<float> _read_float_array(XMLParser &parser); Vector<String> _read_string_array(XMLParser &parser); - Transform _read_transform(XMLParser &parser); + Transform3D _read_transform(XMLParser &parser); String _read_empty_draw_type(XMLParser &parser); void _joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner); diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index d3183e5a8d..a7bfea9d8a 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -87,7 +87,7 @@ struct ColladaImport { Error _create_scene(Collada::Node *p_node, Node3D *p_parent); Error _create_resources(Collada::Node *p_node, bool p_use_compression); Error _create_material(const String &p_target); - Error _create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &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<EditorSceneImporterMesh>> p_morph_meshes = Vector<Ref<EditorSceneImporterMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); + Error _create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<EditorSceneImporterMesh>> p_morph_meshes = Vector<Ref<EditorSceneImporterMesh>>(), 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, bool p_use_compression = false); void _fix_param_animation_tracks(); void create_animation(int p_clip, bool p_make_tracks_in_all_bones, bool p_import_value_tracks); @@ -300,7 +300,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { nm.node = node; node_map[p_node->id] = nm; node_name_map[node->get_name()] = p_node->id; - Transform xf = p_node->default_transform; + Transform3D xf = p_node->default_transform; xf = collada.fix_transform(xf) * p_node->post_transform; node->set_transform(xf); @@ -457,7 +457,7 @@ Error ColladaImport::_create_material(const String &p_target) { return OK; } -Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &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<EditorSceneImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { +Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImporterMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform3D &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<EditorSceneImporterMesh>> p_morph_meshes, bool p_use_compression, bool p_use_mesh_material) { bool local_xform_mirror = p_local_xform.basis.determinant() < 0; if (p_morph_data) { @@ -811,7 +811,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImpor if (has_weights) { //if skeleton, localize - Transform local_xform = p_local_xform; + Transform3D local_xform = p_local_xform; for (int i = 0; i < vertex_array.size(); i++) { vertex_array.write[i].vertex = local_xform.xform(vertex_array[i].vertex); vertex_array.write[i].normal = local_xform.basis.xform(vertex_array[i].normal).normalized(); @@ -1037,7 +1037,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres Collada::SkinControllerData *skin = nullptr; Collada::MorphControllerData *morph = nullptr; String meshid; - Transform apply_xform; + Transform3D apply_xform; Vector<int> bone_remap; Vector<Ref<EditorSceneImporterMesh>> morphs; @@ -1073,9 +1073,9 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres if (apply_mesh_xform_to_vertices) { apply_xform = collada.fix_transform(p_node->default_transform); - node->set_transform(Transform()); + node->set_transform(Transform3D()); } else { - apply_xform = Transform(); + apply_xform = Transform3D(); } ERR_FAIL_COND_V(!skin->weights.sources.has("JOINT"), ERR_INVALID_DATA); @@ -1530,7 +1530,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones } } - Transform xform = cn->compute_transform(collada); + Transform3D xform = cn->compute_transform(collada); xform = collada.fix_transform(xform) * cn->post_transform; if (nm.bone >= 0) { @@ -1589,7 +1589,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones animation->track_set_path(track, path); animation->track_set_imported(track, true); //helps merging later - Transform xform = cn->compute_transform(collada); + Transform3D xform = cn->compute_transform(collada); xform = collada.fix_transform(xform) * cn->post_transform; xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 96002400f3..40aaea3c29 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -433,7 +433,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E p_node->replace_by(rigid_body); rigid_body->set_transform(mi->get_transform()); p_node = rigid_body; - mi->set_transform(Transform()); + mi->set_transform(Transform3D()); rigid_body->add_child(mi); mi->set_owner(rigid_body->get_owner()); @@ -632,7 +632,7 @@ Node *ResourceImporterScene::_post_fix_node(Node *p_node, Node *p_root, Map<Ref< p_node->replace_by(rigid_body); rigid_body->set_transform(mi->get_transform()); p_node = rigid_body; - mi->set_transform(Transform()); + mi->set_transform(Transform3D()); rigid_body->add_child(mi); mi->set_owner(rigid_body->get_owner()); base = rigid_body; @@ -1209,7 +1209,7 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m } if (bake_lightmaps) { - Transform xf; + Transform3D xf; Node3D *n = src_mesh_node; while (n) { xf = n->get_transform() * xf; diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp index 488c124c28..600f3fe2f0 100644 --- a/editor/import/scene_import_settings.cpp +++ b/editor/import/scene_import_settings.cpp @@ -317,7 +317,7 @@ void SceneImportSettings::_fill_scene(Node *p_node, TreeItem *p_parent_item) { if (mesh_node && mesh_node->get_mesh().is_valid()) { _fill_mesh(scene_tree, mesh_node->get_mesh(), item); - Transform accum_xform; + Transform3D accum_xform; Node3D *base = mesh_node; while (base) { accum_xform = base->get_transform() * accum_xform; @@ -379,7 +379,7 @@ void SceneImportSettings::_update_camera() { camera->set_orthogonal(camera_size * zoom, 0.0001, camera_size * 2); - Transform xf; + Transform3D xf; xf.basis = Basis(Vector3(0, 1, 0), rot_y) * Basis(Vector3(1, 0, 0), rot_x); xf.origin = center; xf.translate(0, 0, camera_size); @@ -493,7 +493,7 @@ void SceneImportSettings::_select(Tree *p_from, String p_type, String p_id) { Ref<Mesh> base_mesh = mi->get_mesh(); if (base_mesh.is_valid()) { AABB aabb = base_mesh->get_aabb(); - Transform aabb_xf; + Transform3D aabb_xf; aabb_xf.basis.scale(aabb.size); aabb_xf.origin = aabb.position; @@ -1099,7 +1099,7 @@ SceneImportSettings::SceneImportSettings() { camera->make_current(); light = memnew(DirectionalLight3D); - light->set_transform(Transform().looking_at(Vector3(-1, -2, -0.6), Vector3(0, 1, 0))); + light->set_transform(Transform3D().looking_at(Vector3(-1, -2, -0.6), Vector3(0, 1, 0))); base_viewport->add_child(light); light->set_shadow(true); diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp index fa1a027a8d..bf17ea7bca 100644 --- a/editor/import/scene_importer_mesh.cpp +++ b/editor/import/scene_importer_mesh.cpp @@ -612,7 +612,7 @@ struct EditorSceneImporterMeshLightmapSurface { String name; }; -Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache) { +Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache) { ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED); ERR_FAIL_COND_V_MSG(blend_shapes.size() != 0, ERR_UNAVAILABLE, "Can't unwrap mesh with blend shapes."); @@ -628,7 +628,7 @@ Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform &p_base_tr Basis basis = p_base_transform.get_basis(); Vector3 scale = Vector3(basis.get_axis(0).length(), basis.get_axis(1).length(), basis.get_axis(2).length()); - Transform transform; + Transform3D transform; transform.scale(scale); Basis normal_basis = transform.basis.inverse().transposed(); diff --git a/editor/import/scene_importer_mesh.h b/editor/import/scene_importer_mesh.h index c00339a620..2488de7ed0 100644 --- a/editor/import/scene_importer_mesh.h +++ b/editor/import/scene_importer_mesh.h @@ -106,7 +106,7 @@ public: Vector<Ref<Shape3D>> convex_decompose() const; Ref<Shape3D> create_trimesh_shape() const; Ref<NavigationMesh> create_navigation_mesh(); - Error lightmap_unwrap_cached(const Transform &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache); + Error lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache); void set_lightmap_size_hint(const Size2i &p_size); Size2i get_lightmap_size_hint() const; diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 6265dfc2e4..0e8e9a9a32 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -313,7 +313,7 @@ void InspectorDock::_property_keyed(const String &p_keyed, const Variant &p_valu AnimationPlayerEditor::singleton->get_track_editor()->insert_value_key(p_keyed, p_value, p_advance); } -void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) { +void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform3D &p_key) { Node3D *s = Object::cast_to<Node3D>(sp); if (!s) { return; diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h index 6a3f8c679c..bc16a3b628 100644 --- a/editor/inspector_dock.h +++ b/editor/inspector_dock.h @@ -112,7 +112,7 @@ class InspectorDock : public VBoxContainer { void _prepare_history(); void _property_keyed(const String &p_keyed, const Variant &p_value, bool p_advance); - void _transform_keyed(Object *sp, const String &p_sub, const Transform &p_key); + void _transform_keyed(Object *sp, const String &p_sub, const Transform3D &p_key); protected: static void _bind_methods(); diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index cc261ea868..92feb343c6 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -455,7 +455,7 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector int vc = collision_segments.size(); const Vector3 *vptr = collision_segments.ptr(); - Transform t = spatial_node->get_global_transform(); + Transform3D t = spatial_node->get_global_transform(); bool any_out = false; for (int j = 0; j < fc; j++) { @@ -477,12 +477,12 @@ bool EditorNode3DGizmo::intersect_frustum(const Camera3D *p_camera, const Vector } if (collision_mesh.is_valid()) { - Transform t = spatial_node->get_global_transform(); + Transform3D t = spatial_node->get_global_transform(); Vector3 mesh_scale = t.get_basis().get_scale(); t.orthonormalize(); - Transform it = t.affine_inverse(); + Transform3D it = t.affine_inverse(); Vector<Plane> transformed_frustum; @@ -508,7 +508,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } if (r_gizmo_handle && !hidden) { - Transform t = spatial_node->get_global_transform(); + Transform3D t = spatial_node->get_global_transform(); if (billboard_handle) { t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); } @@ -560,7 +560,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } if (selectable_icon_size > 0.0f) { - Transform t = spatial_node->get_global_transform(); + Transform3D t = spatial_node->get_global_transform(); Vector3 camera_position = p_camera->get_camera_transform().origin; if (camera_position.distance_squared_to(t.origin) > 0.01) { t.set_look_at(t.origin, camera_position); @@ -576,7 +576,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, Point2 center = p_camera->unproject_position(t.origin); - Transform orig_camera_transform = p_camera->get_camera_transform(); + Transform3D orig_camera_transform = p_camera->get_camera_transform(); if (orig_camera_transform.origin.distance_squared_to(t.origin) > 0.01 && ABS(orig_camera_transform.basis.get_axis(Vector3::AXIS_Z).dot(Vector3(0, 1, 0))) < 0.99) { @@ -609,7 +609,7 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, int vc = collision_segments.size(); const Vector3 *vptr = collision_segments.ptr(); - Transform t = spatial_node->get_global_transform(); + Transform3D t = spatial_node->get_global_transform(); if (billboard_handle) { t.set_look_at(t.origin, t.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); } @@ -657,13 +657,13 @@ bool EditorNode3DGizmo::intersect_ray(Camera3D *p_camera, const Point2 &p_point, } if (collision_mesh.is_valid()) { - Transform gt = spatial_node->get_global_transform(); + Transform3D gt = spatial_node->get_global_transform(); if (billboard_handle) { gt.set_look_at(gt.origin, gt.origin - p_camera->get_transform().basis.get_axis(2), p_camera->get_transform().basis.get_axis(1)); } - Transform ai = gt.affine_inverse(); + Transform3D ai = gt.affine_inverse(); Vector3 ray_from = ai.xform(p_camera->project_ray_origin(p_point)); Vector3 ray_dir = ai.basis.xform(p_camera->project_ray_normal(p_point)).normalized(); Vector3 rpos, rnorm; @@ -826,7 +826,7 @@ Variant Light3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_i return Variant(); } -static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vector3 &p_to, float p_arc_radius, const Transform &p_arc_xform) { +static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vector3 &p_to, float p_arc_radius, const Transform3D &p_arc_xform) { //bleh, discrete is simpler static const int arc_test_points = 64; float min_d = 1e20; @@ -855,8 +855,8 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3 &p_from, const Vec void Light3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { Light3D *light = Object::cast_to<Light3D>(p_gizmo->get_spatial_node()); - Transform gt = light->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = light->get_global_transform(); + Transform3D gi = gt.affine_inverse(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -1084,8 +1084,8 @@ Variant AudioStreamPlayer3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gi void AudioStreamPlayer3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); - Transform gt = player->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = player->get_global_transform(); + Transform3D gi = gt.affine_inverse(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -1230,8 +1230,8 @@ Variant Camera3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { Camera3D *camera = Object::cast_to<Camera3D>(p_gizmo->get_spatial_node()); - Transform gt = camera->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = camera->get_global_transform(); + Transform3D gi = gt.affine_inverse(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -1239,7 +1239,7 @@ void Camera3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Came Vector3 s[2] = { gi.xform(ray_from), gi.xform(ray_from + ray_dir * 4096) }; if (camera->get_projection() == Camera3D::PROJECTION_PERSPECTIVE) { - Transform gt2 = camera->get_global_transform(); + Transform3D gt2 = camera->get_global_transform(); float a = _find_closest_angle_to_half_pi_arc(s[0], s[1], 1.0, gt2); camera->set("fov", CLAMP(a * 2.0, 1, 179)); } else { @@ -1418,7 +1418,7 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { lines.push_back(cam_pos); } - Transform local = camera->get_global_transform().affine_inverse(); + Transform3D local = camera->get_global_transform().affine_inverse(); for (int i = 0; i < lines.size(); i++) { lines.write[i] = local.xform(lines[i]); } @@ -1617,7 +1617,7 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { surface_tool->begin(Mesh::PRIMITIVE_LINES); surface_tool->set_material(material); - Vector<Transform> grests; + Vector<Transform3D> grests; grests.resize(skel->get_bone_count()); Vector<int> bones; @@ -1749,7 +1749,7 @@ void Skeleton3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { bones.write[0] = i; } /* - Transform t = grests[i]; + Transform3D t = grests[i]; t.orthonormalize(); for (int i=0;i<6;i++) { @@ -2196,9 +2196,9 @@ Variant VisibilityNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_g void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { VisibilityNotifier3D *notifier = Object::cast_to<VisibilityNotifier3D>(p_gizmo->get_spatial_node()); - Transform gt = notifier->get_global_transform(); + Transform3D gt = notifier->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gi = gt.affine_inverse(); bool move = p_idx >= 3; p_idx = p_idx % 3; @@ -2388,8 +2388,8 @@ Variant GPUParticles3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, void GPUParticles3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_gizmo->get_spatial_node()); - Transform gt = particles->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = particles->get_global_transform(); + Transform3D gi = gt.affine_inverse(); bool move = p_idx >= 3; p_idx = p_idx % 3; @@ -2555,8 +2555,8 @@ Variant GPUParticlesCollision3DGizmoPlugin::get_handle_value(EditorNode3DGizmo * void GPUParticlesCollision3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { Node3D *sn = p_gizmo->get_spatial_node(); - Transform gt = sn->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = sn->get_global_transform(); + Transform3D gi = gt.affine_inverse(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -2814,9 +2814,9 @@ Variant ReflectionProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, void ReflectionProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { ReflectionProbe *probe = Object::cast_to<ReflectionProbe>(p_gizmo->get_spatial_node()); - Transform gt = probe->get_global_transform(); + Transform3D gt = probe->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gi = gt.affine_inverse(); if (p_idx < 3) { Vector3 extents = probe->get_extents(); @@ -2993,9 +2993,9 @@ Variant DecalGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx void DecalGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { Decal *decal = Object::cast_to<Decal>(p_gizmo->get_spatial_node()); - Transform gt = decal->get_global_transform(); + Transform3D gt = decal->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gi = gt.affine_inverse(); Vector3 extents = decal->get_extents(); @@ -3135,8 +3135,8 @@ Variant GIProbeGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_i void GIProbeGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { GIProbe *probe = Object::cast_to<GIProbe>(p_gizmo->get_spatial_node()); - Transform gt = probe->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = probe->get_global_transform(); + Transform3D gi = gt.affine_inverse(); Vector3 extents = probe->get_extents(); @@ -3583,7 +3583,7 @@ void CollisionObject3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { co->get_shape_owners(&owners); for (List<uint32_t>::Element *E = owners.front(); E; E = E->next()) { uint32_t owner_id = E->get(); - Transform xform = co->shape_owner_get_transform(owner_id); + Transform3D xform = co->shape_owner_get_transform(owner_id); Object *owner = co->shape_owner_get_owner(owner_id); // Exclude CollisionShape3D and CollisionPolygon3D as they have their gizmo. if (!Object::cast_to<CollisionShape3D>(owner) && !Object::cast_to<CollisionPolygon3D>(owner)) { @@ -3701,8 +3701,8 @@ void CollisionShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_i return; } - Transform gt = cs->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = cs->get_global_transform(); + Transform3D gi = gt.affine_inverse(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -4369,7 +4369,7 @@ void NavigationRegion3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { #define BODY_A_RADIUS 0.25 #define BODY_B_RADIUS 0.27 -Basis JointGizmosDrawer::look_body(const Transform &p_joint_transform, const Transform &p_body_transform) { +Basis JointGizmosDrawer::look_body(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) { const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_target(p_body_transform.origin); @@ -4394,7 +4394,7 @@ Basis JointGizmosDrawer::look_body(const Transform &p_joint_transform, const Tra return base; } -Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform) { +Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform3D &joint_transform, const Transform3D &body_transform) { switch (p_axis) { case Vector3::AXIS_X: return look_body_toward_x(joint_transform, body_transform); @@ -4407,7 +4407,7 @@ Basis JointGizmosDrawer::look_body_toward(Vector3::Axis p_axis, const Transform } } -Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform) { +Basis JointGizmosDrawer::look_body_toward_x(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) { const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_target(p_body_transform.origin); @@ -4438,7 +4438,7 @@ Basis JointGizmosDrawer::look_body_toward_x(const Transform &p_joint_transform, return base; } -Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform) { +Basis JointGizmosDrawer::look_body_toward_y(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) { const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_target(p_body_transform.origin); @@ -4469,7 +4469,7 @@ Basis JointGizmosDrawer::look_body_toward_y(const Transform &p_joint_transform, return base; } -Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform) { +Basis JointGizmosDrawer::look_body_toward_z(const Transform3D &p_joint_transform, const Transform3D &p_body_transform) { const Vector3 &p_eye(p_joint_transform.origin); const Vector3 &p_target(p_body_transform.origin); @@ -4500,7 +4500,7 @@ Basis JointGizmosDrawer::look_body_toward_z(const Transform &p_joint_transform, return base; } -void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse) { +void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse) { if (p_limit_lower == p_limit_upper) { r_points.push_back(p_offset.translated(Vector3()).origin); r_points.push_back(p_offset.translated(p_base.xform(Vector3(0.5, 0, 0))).origin); @@ -4562,7 +4562,7 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const } } -void JointGizmosDrawer::draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points) { +void JointGizmosDrawer::draw_cone(const Transform3D &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points) { float r = 1.0; float w = r * Math::sin(p_swing); float d = r * Math::cos(p_swing); @@ -4666,7 +4666,7 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Vector<Vector3> body_b_points; if (Object::cast_to<PinJoint3D>(joint)) { - CreatePinJointGizmo(Transform(), points); + CreatePinJointGizmo(Transform3D(), points); p_gizmo->add_collision_segments(points); p_gizmo->add_lines(points, common_material); } @@ -4674,10 +4674,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { HingeJoint3D *hinge = Object::cast_to<HingeJoint3D>(joint); if (hinge) { CreateHingeJointGizmo( - Transform(), + Transform3D(), hinge->get_global_transform(), - node_body_a ? node_body_a->get_global_transform() : Transform(), - node_body_b ? node_body_b->get_global_transform() : Transform(), + node_body_a ? node_body_a->get_global_transform() : Transform3D(), + node_body_b ? node_body_b->get_global_transform() : Transform3D(), hinge->get_param(HingeJoint3D::PARAM_LIMIT_LOWER), hinge->get_param(HingeJoint3D::PARAM_LIMIT_UPPER), hinge->get_flag(HingeJoint3D::FLAG_USE_LIMIT), @@ -4697,10 +4697,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { SliderJoint3D *slider = Object::cast_to<SliderJoint3D>(joint); if (slider) { CreateSliderJointGizmo( - Transform(), + Transform3D(), slider->get_global_transform(), - node_body_a ? node_body_a->get_global_transform() : Transform(), - node_body_b ? node_body_b->get_global_transform() : Transform(), + node_body_a ? node_body_a->get_global_transform() : Transform3D(), + node_body_b ? node_body_b->get_global_transform() : Transform3D(), slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_LOWER), slider->get_param(SliderJoint3D::PARAM_ANGULAR_LIMIT_UPPER), slider->get_param(SliderJoint3D::PARAM_LINEAR_LIMIT_LOWER), @@ -4721,10 +4721,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { ConeTwistJoint3D *cone = Object::cast_to<ConeTwistJoint3D>(joint); if (cone) { CreateConeTwistJointGizmo( - Transform(), + Transform3D(), cone->get_global_transform(), - node_body_a ? node_body_a->get_global_transform() : Transform(), - node_body_b ? node_body_b->get_global_transform() : Transform(), + node_body_a ? node_body_a->get_global_transform() : Transform3D(), + node_body_b ? node_body_b->get_global_transform() : Transform3D(), cone->get_param(ConeTwistJoint3D::PARAM_SWING_SPAN), cone->get_param(ConeTwistJoint3D::PARAM_TWIST_SPAN), node_body_a ? &body_a_points : nullptr, @@ -4740,10 +4740,10 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { Generic6DOFJoint3D *gen = Object::cast_to<Generic6DOFJoint3D>(joint); if (gen) { CreateGeneric6DOFJointGizmo( - Transform(), + Transform3D(), gen->get_global_transform(), - node_body_a ? node_body_a->get_global_transform() : Transform(), - node_body_b ? node_body_b->get_global_transform() : Transform(), + node_body_a ? node_body_a->get_global_transform() : Transform3D(), + node_body_b ? node_body_b->get_global_transform() : Transform3D(), gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_LOWER_LIMIT), gen->get_param_x(Generic6DOFJoint3D::PARAM_ANGULAR_UPPER_LIMIT), @@ -4780,7 +4780,7 @@ void Joint3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { } } -void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points) { +void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform3D &p_offset, Vector<Vector3> &r_cursor_points) { float cs = 0.25; r_cursor_points.push_back(p_offset.translated(Vector3(+cs, 0, 0)).origin); @@ -4791,7 +4791,7 @@ void Joint3DGizmoPlugin::CreatePinJointGizmo(const Transform &p_offset, Vector<V r_cursor_points.push_back(p_offset.translated(Vector3(0, 0, -cs)).origin); } -void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { +void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { r_common_points.push_back(p_offset.translated(Vector3(0, 0, 0.5)).origin); r_common_points.push_back(p_offset.translated(Vector3(0, 0, -0.5)).origin); @@ -4821,7 +4821,7 @@ void Joint3DGizmoPlugin::CreateHingeJointGizmo(const Transform &p_offset, const } } -void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { +void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { p_linear_limit_lower = -p_linear_limit_lower; p_linear_limit_upper = -p_linear_limit_upper; @@ -4880,7 +4880,7 @@ void Joint3DGizmoPlugin::CreateSliderJointGizmo(const Transform &p_offset, const } } -void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { +void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points) { if (r_body_a_points) { JointGizmosDrawer::draw_cone( p_offset, @@ -4901,10 +4901,10 @@ void Joint3DGizmoPlugin::CreateConeTwistJointGizmo(const Transform &p_offset, co } void Joint3DGizmoPlugin::CreateGeneric6DOFJointGizmo( - const Transform &p_offset, - const Transform &p_trs_joint, - const Transform &p_trs_body_a, - const Transform &p_trs_body_b, + const Transform3D &p_offset, + const Transform3D &p_trs_joint, + const Transform3D &p_trs_body_a, + const Transform3D &p_trs_body_b, real_t p_angular_limit_lower_x, real_t p_angular_limit_upper_x, real_t p_linear_limit_lower_x, diff --git a/editor/node_3d_editor_gizmos.h b/editor/node_3d_editor_gizmos.h index 95344176ad..25958d1ad7 100644 --- a/editor/node_3d_editor_gizmos.h +++ b/editor/node_3d_editor_gizmos.h @@ -428,17 +428,17 @@ public: class JointGizmosDrawer { public: - static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform); - static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform); - static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform); - static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform); + static Basis look_body(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); + static Basis look_body_toward(Vector3::Axis p_axis, const Transform3D &joint_transform, const Transform3D &body_transform); + static Basis look_body_toward_x(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); + static Basis look_body_toward_y(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); /// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis /// with axis X and Y that are looking toward the body and oriented toward up - static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform); + static Basis look_body_toward_z(const Transform3D &p_joint_transform, const Transform3D &p_body_transform); // Draw circle around p_axis - static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false); - static void draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points); + static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false); + static void draw_cone(const Transform3D &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points); }; class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin { @@ -455,15 +455,15 @@ public: int get_priority() const override; void redraw(EditorNode3DGizmo *p_gizmo) override; - static void CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points); - static void CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); - static void CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); - static void CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); + static void CreatePinJointGizmo(const Transform3D &p_offset, Vector<Vector3> &r_cursor_points); + static void CreateHingeJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); + static void CreateSliderJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); + static void CreateConeTwistJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points); static void CreateGeneric6DOFJointGizmo( - const Transform &p_offset, - const Transform &p_trs_joint, - const Transform &p_trs_body_a, - const Transform &p_trs_body_b, + const Transform3D &p_offset, + const Transform3D &p_trs_joint, + const Transform3D &p_trs_body_a, + const Transform3D &p_trs_body_b, real_t p_angular_limit_lower_x, real_t p_angular_limit_upper_x, real_t p_linear_limit_lower_x, diff --git a/editor/plugins/collision_polygon_3d_editor_plugin.cpp b/editor/plugins/collision_polygon_3d_editor_plugin.cpp index 252e5c68a0..6e71133c4f 100644 --- a/editor/plugins/collision_polygon_3d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_3d_editor_plugin.cpp @@ -108,8 +108,8 @@ bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, con return false; } - Transform gt = node->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = node->get_global_transform(); + Transform3D gi = gt.affine_inverse(); float depth = _get_depth() * 0.5; Vector3 n = gt.basis.get_axis(2).normalized(); Plane p(gt.origin + n * depth, n); @@ -516,7 +516,7 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { mode = MODE_EDIT; wip_active = false; imgeom = memnew(ImmediateGeometry3D); - imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); + imgeom->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001))); line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); @@ -539,7 +539,7 @@ CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) { imgeom->add_child(pointsm); m.instance(); pointsm->set_mesh(m); - pointsm->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); + pointsm->set_transform(Transform3D(Basis(), Vector3(0, 0, 0.00001))); snap_ignore = false; } diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 2d79e4f3e3..cf237f5a4a 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -359,12 +359,12 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { camera = RS::get_singleton()->camera_create(); RS::get_singleton()->viewport_attach_camera(viewport, camera); - RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_transform(camera, Transform3D(Basis(), Vector3(0, 0, 3))); RS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); light = RS::get_singleton()->directional_light_create(); light_instance = RS::get_singleton()->instance_create2(light, scenario); - RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance, Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); light2 = RS::get_singleton()->directional_light_create(); RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); @@ -372,7 +372,7 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); - RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + RS::get_singleton()->instance_set_transform(light_instance2, Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); sphere = RS::get_singleton()->mesh_create(); sphere_instance = RS::get_singleton()->instance_create2(sphere, scenario); @@ -720,7 +720,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; - Transform xform; + Transform3D xform; xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125); xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis; AABB rot_aabb = xform.xform(aabb); @@ -780,20 +780,20 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { camera = RS::get_singleton()->camera_create(); RS::get_singleton()->viewport_attach_camera(viewport, camera); - RS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); + RS::get_singleton()->camera_set_transform(camera, Transform3D(Basis(), Vector3(0, 0, 3))); //RS::get_singleton()->camera_set_perspective(camera,45,0.1,10); RS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); light = RS::get_singleton()->directional_light_create(); light_instance = RS::get_singleton()->instance_create2(light, scenario); - RS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + RS::get_singleton()->instance_set_transform(light_instance, Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); light2 = RS::get_singleton()->directional_light_create(); RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //RS::get_singleton()->light_set_color(light2, RS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); light_instance2 = RS::get_singleton()->instance_create2(light2, scenario); - RS::get_singleton()->instance_set_transform(light_instance2, Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + RS::get_singleton()->instance_set_transform(light_instance2, Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); //sphere = RS::get_singleton()->mesh_create(); mesh_instance = RS::get_singleton()->instance_create(); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 89d6aaa5f9..17c7397729 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -177,7 +177,7 @@ void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) { return; } - Transform geom_xform = base_node->get_global_transform().affine_inverse() * vi->get_global_transform(); + Transform3D geom_xform = base_node->get_global_transform().affine_inverse() * vi->get_global_transform(); int gc = geometry.size(); Face3 *w = geometry.ptrw(); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index ad99ad7808..81f0ecacf2 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -119,17 +119,17 @@ MaterialEditor::MaterialEditor() { viewport->set_msaa(Viewport::MSAA_4X); camera = memnew(Camera3D); - camera->set_transform(Transform(Basis(), Vector3(0, 0, 3))); + camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 3))); camera->set_perspective(45, 0.1, 10); camera->make_current(); viewport->add_child(camera); light1 = memnew(DirectionalLight3D); - light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + light1->set_transform(Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); viewport->add_child(light1); light2 = memnew(DirectionalLight3D); - light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + light2->set_transform(Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); light2->set_color(Color(0.7, 0.7, 0.7)); viewport->add_child(light2); @@ -139,7 +139,7 @@ MaterialEditor::MaterialEditor() { box_instance = memnew(MeshInstance3D); viewport->add_child(box_instance); - Transform box_xform; + Transform3D box_xform; box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0)); box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0)); box_xform.basis.scale(Vector3(0.8, 0.8, 0.8)); diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 9d29c31522..8d488dce20 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -65,7 +65,7 @@ void MeshEditor::_notification(int p_what) { } void MeshEditor::_update_rotation() { - Transform t; + Transform3D t; t.basis.rotate(Vector3(0, 1, 0), -rot_y); t.basis.rotate(Vector3(1, 0, 0), -rot_x); rotation->set_transform(t); @@ -85,7 +85,7 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) { if (m != 0) { m = 1.0 / m; m *= 0.5; - Transform xform; + Transform3D xform; xform.basis.scale(Vector3(m, m, m)); xform.origin = -xform.basis.xform(ofs); //-ofs*m; //xform.origin.z -= aabb.get_longest_axis_size() * 2; @@ -117,16 +117,16 @@ MeshEditor::MeshEditor() { viewport->set_msaa(Viewport::MSAA_2X); set_stretch(true); camera = memnew(Camera3D); - camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1))); + camera->set_transform(Transform3D(Basis(), Vector3(0, 0, 1.1))); camera->set_perspective(45, 0.1, 10); viewport->add_child(camera); light1 = memnew(DirectionalLight3D); - light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); + light1->set_transform(Transform3D().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); viewport->add_child(light1); light2 = memnew(DirectionalLight3D); - light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); + light2->set_transform(Transform3D().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1))); light2->set_color(Color(0.7, 0.7, 0.7)); viewport->add_child(light2); diff --git a/editor/plugins/mesh_library_editor_plugin.cpp b/editor/plugins/mesh_library_editor_plugin.cpp index 6f1f243444..e64992759d 100644 --- a/editor/plugins/mesh_library_editor_plugin.cpp +++ b/editor/plugins/mesh_library_editor_plugin.cpp @@ -127,7 +127,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, continue; } - //Transform shape_transform = sb->shape_owner_get_transform(E->get()); + //Transform3D shape_transform = sb->shape_owner_get_transform(E->get()); //shape_transform.set_origin(shape_transform.get_origin() - phys_offset); @@ -147,7 +147,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, p_library->set_item_shapes(id, collisions); Ref<NavigationMesh> navmesh; - Transform navmesh_transform; + Transform3D navmesh_transform; for (int j = 0; j < mi->get_child_count(); j++) { Node *child2 = mi->get_child(j); if (!Object::cast_to<NavigationRegion3D>(child2)) { @@ -170,7 +170,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, if (true) { Vector<Ref<Mesh>> meshes; - Vector<Transform> transforms; + Vector<Transform3D> transforms; Vector<int> ids = p_library->get_item_list(); for (int i = 0; i < ids.size(); i++) { if (mesh_instances.find(ids[i])) { diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 19c6dcf402..48b885930f 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -111,7 +111,7 @@ void MultiMeshEditor::_populate() { return; } - Transform geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform(); + Transform3D geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform(); Vector<Face3> geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID); @@ -167,7 +167,7 @@ void MultiMeshEditor::_populate() { float _scale = populate_scale->get_value(); int axis = populate_axis->get_selected(); - Transform axis_xform; + Transform3D axis_xform; if (axis == Vector3::AXIS_Z) { axis_xform.rotate(Vector3(1, 0, 0), -Math_PI * 0.5); } @@ -191,7 +191,7 @@ void MultiMeshEditor::_populate() { Vector3 normal = face.get_plane().normal; Vector3 op_axis = (face.vertex[0] - face.vertex[1]).normalized(); - Transform xform; + Transform3D xform; xform.set_look_at(pos, pos + op_axis, normal); xform = xform * axis_xform; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index ba39ce3aed..b87cbd9eb6 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -361,8 +361,8 @@ void Node3DEditorViewport::_update_camera(float p_interp_delta) { } } -Transform Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const { - Transform camera_transform; +Transform3D Node3DEditorViewport::to_camera_transform(const Cursor &p_cursor) const { + Transform3D camera_transform; camera_transform.translate(p_cursor.pos); camera_transform.basis.rotate(Vector3(1, 0, 0), -p_cursor.x_rot); camera_transform.basis.rotate(Vector3(0, 1, 0), -p_cursor.y_rot); @@ -410,7 +410,7 @@ float Node3DEditorViewport::get_fov() const { return CLAMP(spatial_editor->get_fov(), MIN_FOV, MAX_FOV); } -Transform Node3DEditorViewport::_get_camera_transform() const { +Transform3D Node3DEditorViewport::_get_camera_transform() const { return camera->get_global_transform(); } @@ -631,7 +631,7 @@ Vector3 Node3DEditorViewport::_get_screen_to_space(const Vector3 &p_vector3) { } Vector2 screen_he = cm.get_viewport_half_extents(); - Transform camera_transform; + Transform3D camera_transform; camera_transform.translate(cursor.pos); camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); camera_transform.basis.rotate(Vector3(0, 1, 0), -cursor.y_rot); @@ -829,7 +829,7 @@ bool Node3DEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_high Vector3 ray_pos = _get_ray_pos(Vector2(p_screenpos.x, p_screenpos.y)); Vector3 ray = _get_ray(Vector2(p_screenpos.x, p_screenpos.y)); - Transform gt = spatial_editor->get_gizmo_transform(); + Transform3D gt = spatial_editor->get_gizmo_transform(); float gs = gizmo_scale; if (spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == Node3DEditor::TOOL_MODE_MOVE) { @@ -1579,10 +1579,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform original = se->original; - Transform original_local = se->original_local; - Transform base = Transform(Basis(), _edit.center); - Transform t; + Transform3D original = se->original; + Transform3D original_local = se->original_local; + Transform3D base = Transform3D(Basis(), _edit.center); + Transform3D t; Vector3 local_scale; if (local_coords) { @@ -1608,7 +1608,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { motion.snap(Vector3(snap, snap, snap)); } - Transform r; + Transform3D r; r.basis.scale(motion + Vector3(1, 1, 1)); t = base * (r * (base.inverse() * original)); @@ -1701,8 +1701,8 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform original = se->original; - Transform t; + Transform3D original = se->original; + Transform3D t; if (local_coords) { if (_edit.snap || spatial_editor->is_snap_enabled()) { @@ -1797,10 +1797,10 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform t; + Transform3D t; if (local_coords) { - Transform original_local = se->original_local; + Transform3D original_local = se->original_local; Basis rot = Basis(axis, angle); t.basis = original_local.get_basis().orthonormalized() * rot; @@ -1811,9 +1811,9 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { sp->set_scale(original_local.basis.get_scale()); // re-apply original scale } else { - Transform original = se->original; - Transform r; - Transform base = Transform(Basis(), _edit.center); + Transform3D original = se->original; + Transform3D r; + Transform3D base = Transform3D(Basis(), _edit.center); r.basis.rotate(plane.normal, angle); t = base * r * base.inverse() * original; @@ -2057,7 +2057,7 @@ void Node3DEditorViewport::_nav_pan(Ref<InputEventWithModifiers> p_event, const pan_speed *= pan_speed_modifier; } - Transform camera_transform; + Transform3D camera_transform; camera_transform.translate(cursor.pos); camera_transform.basis.rotate(Vector3(1, 0, 0), -cursor.x_rot); @@ -2145,7 +2145,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const const bool invert_y_axis = EditorSettings::get_singleton()->get("editors/3d/navigation/invert_y_axis"); // Note: do NOT assume the camera has the "current" transform, because it is interpolated and may have "lag". - const Transform prev_camera_transform = to_camera_transform(cursor); + const Transform3D prev_camera_transform = to_camera_transform(cursor); if (invert_y_axis) { cursor.x_rot -= p_relative.y * radians_per_pixel; @@ -2158,7 +2158,7 @@ void Node3DEditorViewport::_nav_look(Ref<InputEventWithModifiers> p_event, const cursor.y_rot += p_relative.x * radians_per_pixel; // Look is like the opposite of Orbit: the focus point rotates around the camera - Transform camera_transform = to_camera_transform(cursor); + Transform3D camera_transform = to_camera_transform(cursor); Vector3 pos = camera_transform.xform(Vector3(0, 0, 0)); Vector3 prev_pos = prev_camera_transform.xform(Vector3(0, 0, 0)); Vector3 diff = prev_pos - pos; @@ -2444,7 +2444,7 @@ void Node3DEditorViewport::_notification(int p_what) { continue; } - Transform t = sp->get_global_gizmo_transform(); + Transform3D t = sp->get_global_gizmo_transform(); VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sp); AABB new_aabb = vi ? vi->get_aabb() : _calculate_spatial_bounds(sp); @@ -2878,7 +2878,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { break; } - Transform camera_transform = camera->get_global_transform(); + Transform3D camera_transform = camera->get_global_transform(); List<Node *> &selection = editor_selection->get_selected_node_list(); @@ -2895,7 +2895,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { continue; } - Transform xform; + Transform3D xform; if (orthogonal) { xform = sp->get_global_transform(); xform.basis.set_euler(camera_transform.basis.get_euler()); @@ -2915,7 +2915,7 @@ void Node3DEditorViewport::_menu_option(int p_option) { break; } - Transform camera_transform = camera->get_global_transform(); + Transform3D camera_transform = camera->get_global_transform(); List<Node *> &selection = editor_selection->get_selected_node_list(); @@ -3315,9 +3315,9 @@ void Node3DEditorViewport::update_transform_gizmo_view() { return; } - Transform xform = spatial_editor->get_gizmo_transform(); + Transform3D xform = spatial_editor->get_gizmo_transform(); - Transform camera_xform = camera->get_transform(); + Transform3D camera_xform = camera->get_transform(); if (xform.origin.distance_squared_to(camera_xform.origin) < 0.01) { for (int i = 0; i < 3; i++) { @@ -3800,7 +3800,7 @@ bool Node3DEditorViewport::_create_instance(Node *parent, String &path, const Po Node3D *node3d = Object::cast_to<Node3D>(instanced_scene); if (node3d) { - Transform global_transform; + Transform3D global_transform; Node3D *parent_node3d = Object::cast_to<Node3D>(parent); if (parent_node3d) { global_transform = parent_node3d->get_global_gizmo_transform(); @@ -3900,7 +3900,7 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant } if (can_instance) { - Transform global_transform = Transform(Basis(), _get_instance_position(p_point)); + Transform3D global_transform = Transform3D(Basis(), _get_instance_position(p_point)); preview_node->set_global_transform(global_transform); } @@ -4574,7 +4574,7 @@ void Node3DEditor::update_transform_gizmo() { continue; } - Transform xf = se->sp->get_global_gizmo_transform(); + Transform3D xf = se->sp->get_global_gizmo_transform(); if (first) { center.position = xf.origin; @@ -4955,7 +4955,7 @@ void Node3DEditor::_snap_update() { } void Node3DEditor::_xform_dialog_action() { - Transform t; + Transform3D t; //translation Vector3 scale; Vector3 rotate; @@ -4988,7 +4988,7 @@ void Node3DEditor::_xform_dialog_action() { bool post = xform_type->get_selected() > 0; - Transform tr = sp->get_global_gizmo_transform(); + Transform3D tr = sp->get_global_gizmo_transform(); if (post) { tr = tr * t; } else { @@ -6180,7 +6180,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() { if (ss->intersect_ray(from, to, result, excluded)) { Vector3 position_offset = d["position_offset"]; - Transform new_transform = sp->get_global_transform(); + Transform3D new_transform = sp->get_global_transform(); new_transform.origin.y = result.position.y; new_transform.origin = new_transform.origin - position_offset; @@ -6556,7 +6556,7 @@ void Node3DEditor::_preview_settings_changed() { } { // preview sun - Transform t; + Transform3D t; t.basis = sun_rotation; preview_sun->set_transform(t); sun_direction->update(); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index 33f4c32471..186e97fd15 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -322,7 +322,7 @@ private: Vector3 _get_ray_pos(const Vector2 &p_pos) const; Vector3 _get_ray(const Vector2 &p_pos) const; Point2 _point_to_screen(const Vector3 &p_point); - Transform _get_camera_transform() const; + Transform3D _get_camera_transform() const; int get_selected_count() const; Vector3 _get_camera_position() const; @@ -380,7 +380,7 @@ private: struct EditData { TransformMode mode; TransformPlane plane; - Transform original; + Transform3D original; Vector3 click_ray; Vector3 click_ray_pos; Vector3 center; @@ -432,7 +432,7 @@ private: // void _update_camera(float p_interp_delta); - Transform to_camera_transform(const Cursor &p_cursor) const; + Transform3D to_camera_transform(const Cursor &p_cursor) const; void _draw(); void _surface_mouse_enter(); @@ -505,9 +505,9 @@ class Node3DEditorSelectedItem : public Object { public: AABB aabb; - Transform original; // original location when moving - Transform original_local; - Transform last_xform; // last transform + Transform3D original; // original location when moving + Transform3D original_local; + Transform3D last_xform; // last transform bool last_xform_dirty; Node3D *sp; RID sbox_instance; @@ -641,7 +641,7 @@ private: struct Gizmo { bool visible = false; float scale = 0; - Transform transform; + Transform3D transform; } gizmo; enum MenuOption { @@ -824,7 +824,7 @@ public: float get_zfar() const { return settings_zfar->get_value(); } float get_fov() const { return settings_fov->get_value(); } - Transform get_gizmo_transform() const { return gizmo.transform; } + Transform3D get_gizmo_transform() const { return gizmo.transform; } bool is_gizmo_visible() const { return gizmo.visible; } ToolMode get_tool_mode() const { return tool_mode; } diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index 8c73294723..b0eb13c3c6 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -94,8 +94,8 @@ void Path3DGizmo::set_handle(int p_idx, Camera3D *p_camera, const Point2 &p_poin return; } - Transform gt = path->get_global_transform(); - Transform gi = gt.affine_inverse(); + Transform3D gt = path->get_global_transform(); + Transform3D gi = gt.affine_inverse(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -302,8 +302,8 @@ bool Path3DEditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref if (c.is_null()) { return false; } - Transform gt = path->get_global_transform(); - Transform it = gt.affine_inverse(); + Transform3D gt = path->get_global_transform(); + Transform3D it = gt.affine_inverse(); static const int click_dist = 10; //should make global diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index 404ef62eca..0a20d8daba 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -171,7 +171,7 @@ void BoneTransformEditor::_value_changed(const double p_value) { return; } - Transform tform = compute_transform_from_vector3s(); + Transform3D tform = compute_transform_from_vector3s(); _change_transform(tform); } @@ -179,30 +179,30 @@ void BoneTransformEditor::_value_changed_vector3(const String p_property_name, c if (updating) { return; } - Transform tform = compute_transform_from_vector3s(); + Transform3D tform = compute_transform_from_vector3s(); _change_transform(tform); } -Transform BoneTransformEditor::compute_transform_from_vector3s() const { +Transform3D BoneTransformEditor::compute_transform_from_vector3s() const { // Convert rotation from degrees to radians. Vector3 prop_rotation = rotation_property->get_vector(); prop_rotation.x = Math::deg2rad(prop_rotation.x); prop_rotation.y = Math::deg2rad(prop_rotation.y); prop_rotation.z = Math::deg2rad(prop_rotation.z); - return Transform( + return Transform3D( Basis(prop_rotation, scale_property->get_vector()), translation_property->get_vector()); } -void BoneTransformEditor::_value_changed_transform(const String p_property_name, const Transform p_transform, const StringName p_edited_property_name, const bool p_boolean) { +void BoneTransformEditor::_value_changed_transform(const String p_property_name, const Transform3D p_transform, const StringName p_edited_property_name, const bool p_boolean) { if (updating) { return; } _change_transform(p_transform); } -void BoneTransformEditor::_change_transform(Transform p_new_transform) { +void BoneTransformEditor::_change_transform(Transform3D p_new_transform) { if (property.get_slicec('/', 0) == "bones" && property.get_slicec('/', 2) == "custom_pose") { undo_redo->create_action(TTR("Set Custom Bone Pose Transform"), UndoRedo::MERGE_ENDS); undo_redo->add_undo_method(skeleton, "set_bone_custom_pose", property.get_slicec('/', 1).to_int(), skeleton->get_bone_custom_pose(property.get_slicec('/', 1).to_int())); @@ -235,7 +235,7 @@ void BoneTransformEditor::_update_properties() { updating = true; - Transform tform = skeleton->get(property); + Transform3D tform = skeleton->get(property); _update_transform_properties(tform); } @@ -250,11 +250,11 @@ void BoneTransformEditor::_update_custom_pose_properties() { updating = true; - Transform tform = skeleton->get_bone_custom_pose(property.to_int()); + Transform3D tform = skeleton->get_bone_custom_pose(property.to_int()); _update_transform_properties(tform); } -void BoneTransformEditor::_update_transform_properties(Transform tform) { +void BoneTransformEditor::_update_transform_properties(Transform3D tform) { Basis rotation_basis = tform.get_basis(); Vector3 rotation_radians = rotation_basis.get_rotation_euler(); Vector3 rotation_degrees = Vector3(Math::rad2deg(rotation_radians.x), Math::rad2deg(rotation_radians.y), Math::rad2deg(rotation_radians.z)); @@ -306,7 +306,7 @@ void BoneTransformEditor::_key_button_pressed() { } // Need to normalize the basis before you key it - Transform tform = compute_transform_from_vector3s(); + Transform3D tform = compute_transform_from_vector3s(); tform.orthonormalize(); AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(skeleton, name, tform); } @@ -380,7 +380,7 @@ void Skeleton3DEditor::create_physical_skeleton() { } PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) { - const Transform child_rest = skeleton->get_bone_rest(bone_child_id); + const Transform3D child_rest = skeleton->get_bone_rest(bone_child_id); const real_t half_height(child_rest.origin.length() * 0.5); const real_t radius(half_height * 0.2); @@ -392,15 +392,15 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi CollisionShape3D *bone_shape = memnew(CollisionShape3D); bone_shape->set_shape(bone_shape_capsule); - Transform capsule_transform; + Transform3D capsule_transform; capsule_transform.basis = Basis(Vector3(1, 0, 0), Vector3(0, 0, 1), Vector3(0, -1, 0)); bone_shape->set_transform(capsule_transform); - Transform body_transform; + Transform3D body_transform; body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin); body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height)); - Transform joint_transform; + Transform3D joint_transform; joint_transform.origin = Vector3(0, 0, half_height); PhysicalBone3D *physical_bone = memnew(PhysicalBone3D); diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h index 14c213f7b2..a312f84f53 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.h +++ b/editor/plugins/skeleton_3d_editor_plugin.h @@ -78,11 +78,11 @@ class BoneTransformEditor : public VBoxContainer { // Called when the one of the EditorPropertyVector3 are updated. void _value_changed_vector3(const String p_property_name, const Vector3 p_vector, const StringName p_edited_property_name, const bool p_boolean); // Called when the transform_property is updated. - void _value_changed_transform(const String p_property_name, const Transform p_transform, const StringName p_edited_property_name, const bool p_boolean); + void _value_changed_transform(const String p_property_name, const Transform3D p_transform, const StringName p_edited_property_name, const bool p_boolean); // Changes the transform to the given transform and updates the UI accordingly. - void _change_transform(Transform p_new_transform); + void _change_transform(Transform3D p_new_transform); // Creates a Transform using the EditorPropertyVector3 properties. - Transform compute_transform_from_vector3s() const; + Transform3D compute_transform_from_vector3s() const; void update_enabled_checkbox(); @@ -98,7 +98,7 @@ public: void _update_properties(); void _update_custom_pose_properties(); - void _update_transform_properties(Transform p_transform); + void _update_transform_properties(Transform3D p_transform); // Can/cannot modify the spinner values for the Transform void set_read_only(const bool p_read_only); @@ -127,7 +127,7 @@ class Skeleton3DEditor : public VBoxContainer { struct BoneInfo { PhysicalBone3D *physical_bone = nullptr; - Transform relative_rest; // Relative to skeleton node + Transform3D relative_rest; // Relative to skeleton node }; EditorNode *editor; diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 8b0d9ae0fc..287d9aa4d9 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -806,7 +806,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: field_names.push_back("zo"); config_value_editors(12, 4, 16, field_names); - Transform tr = v; + Transform3D tr = v; for (int i = 0; i < 9; i++) { value_editor[(i / 3) * 4 + i % 3]->set_text(String::num(tr.basis.elements[i / 3][i % 3])); } @@ -1569,7 +1569,7 @@ void CustomPropertyEditor::_modified(String p_string) { origin.y = _parse_real_expression(value_editor[7]->get_text()); origin.z = _parse_real_expression(value_editor[11]->get_text()); - v = Transform(basis, origin); + v = Transform3D(basis, origin); _emit_changed_whole_or_field(); } break; diff --git a/editor/shader_globals_editor.cpp b/editor/shader_globals_editor.cpp index ebef5be9ed..50e6cea4a2 100644 --- a/editor/shader_globals_editor.cpp +++ b/editor/shader_globals_editor.cpp @@ -326,7 +326,7 @@ static Variant create_var(RS::GlobalVariableType p_type) { return Transform2D(); } case RS::GLOBAL_VAR_TYPE_TRANSFORM: { - return Transform(); + return Transform3D(); } case RS::GLOBAL_VAR_TYPE_MAT4: { Vector<real_t> xform; |