Skip to content

Commit 5e2a13b

Browse files
Restore code that got merged out by mistake. (o3de#582)
Signed-off-by: Mike Balfour <[email protected]>
1 parent 0f83de6 commit 5e2a13b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Gems/ROS2/Code/Source/RobotImporter/Utils/SourceAssetsStorage.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,28 @@ namespace ROS2::Utils
510510

511511
bool CreateSceneManifest(const AZ::IO::Path& sourceAssetPath, const AZ::IO::Path& assetInfoFile, const bool collider, const bool visual)
512512
{
513+
// Start with a default set of import settings.
514+
AZ::SceneAPI::SceneImportSettings importSettings;
515+
516+
// OBJ files used for robotics might be authored with hundreds or thousands of tiny groups of meshes. By default,
517+
// AssImp splits each object or group in an OBJ into a separate submesh, creating an extremely non-optimal result.
518+
// By turning on the AssImp options to optimize the scene and the meshes, all of these submeshes will get recombined
519+
// back into just a few submeshes.
520+
if (sourceAssetPath.Extension() == ".obj")
521+
{
522+
importSettings.m_optimizeScene = true;
523+
importSettings.m_optimizeMeshes = true;
524+
}
525+
526+
// Set the import settings into the settings registry.
527+
// This needs to happen before calling LoadScene so that the AssImp import settings are applied to the scene being
528+
// read into memory. These settings affect the list of scene nodes referenced by the MeshGroup and PhysXGroup settings,
529+
// so it's important to apply them here to get the proper node lists.
530+
if (AZ::SettingsRegistryInterface* settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry)
531+
{
532+
settingsRegistry->SetObject(AZ::SceneAPI::DataTypes::IImportGroup::SceneImportSettingsRegistryKey, importSettings);
533+
}
534+
513535
AZ_Printf("CreateSceneManifest", "Creating manifest for asset %s at : %s ", sourceAssetPath.c_str(), assetInfoFile.c_str());
514536
AZStd::shared_ptr<AZ::SceneAPI::Containers::Scene> scene;
515537
AZ::SceneAPI::Events::SceneSerializationBus::BroadcastResult(

0 commit comments

Comments
 (0)