diff options
| author | Juan Linietsky | 2016-05-27 14:18:40 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-05-27 14:19:11 -0300 |
| commit | 8be2fabbe5cd846bac5e5a38e55f3fb70e73f2da (patch) | |
| tree | a3e932282cdafdd13c4f02bdf21f72f9846adcbe /tools/editor/plugins/mesh_editor_plugin.cpp | |
| parent | eb7227a20b27e91c6e2adfb1ded738f2dd7e453b (diff) | |
| download | godot-8be2fabbe5cd846bac5e5a38e55f3fb70e73f2da.tar.gz godot-8be2fabbe5cd846bac5e5a38e55f3fb70e73f2da.tar.zst godot-8be2fabbe5cd846bac5e5a38e55f3fb70e73f2da.zip | |
Diffstat (limited to 'tools/editor/plugins/mesh_editor_plugin.cpp')
| -rw-r--r-- | tools/editor/plugins/mesh_editor_plugin.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/editor/plugins/mesh_editor_plugin.cpp b/tools/editor/plugins/mesh_editor_plugin.cpp index c4f44f608..ecf17fec1 100644 --- a/tools/editor/plugins/mesh_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_editor_plugin.cpp @@ -71,6 +71,22 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) { rot_x=0; rot_y=0; _update_rotation(); + + AABB aabb= mesh->get_aabb(); + Vector3 ofs = aabb.pos + aabb.size*0.5; + aabb.pos-=ofs; + float m = MAX(aabb.size.x,aabb.size.y)*0.5; + if (m!=0) { + m=1.0/m; + m*=0.5; + //print_line("scale: "+rtos(m)); + Transform xform; + xform.basis.scale(Vector3(m,m,m)); + xform.origin=-xform.basis.xform(ofs); //-ofs*m; + xform.origin.z-=aabb.size.z*2; + mesh_instance->set_transform(xform); + } + } } |
