Consider StaticBody and NavMesh position when converting to a MeshLibrary

Would have added mesh transform, but realized that will cause problems when moving the mesh around the scene for visualization purposes.

Closes #11722
This commit is contained in:
Bojidar Marinov
2019-02-26 15:38:23 +02:00
parent 22ee7ba4f0
commit 1a397a7878
4 changed files with 34 additions and 2 deletions

View File

@ -127,7 +127,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
continue;
MeshLibrary::ShapeData shape_data;
shape_data.shape = collision;
shape_data.local_transform = sb->shape_owner_get_transform(E->get());
shape_data.local_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get());
collisions.push_back(shape_data);
}
}
@ -136,17 +136,20 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
p_library->set_item_shapes(id, collisions);
Ref<NavigationMesh> navmesh;
Transform navmesh_transform;
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
if (!Object::cast_to<NavigationMeshInstance>(child2))
continue;
NavigationMeshInstance *sb = Object::cast_to<NavigationMeshInstance>(child2);
navmesh = sb->get_navigation_mesh();
navmesh_transform = sb->get_transform();
if (!navmesh.is_null())
break;
}
if (!navmesh.is_null()) {
p_library->set_item_navmesh(id, navmesh);
p_library->set_item_navmesh_transform(id, navmesh_transform);
}
}