Merge branch 'skip-existing-mats' of https://github.com/Menotdan/FlaxEngine into Menotdan-skip-existing-mats
This commit is contained in:
@@ -374,6 +374,7 @@ void ModelTool::Options::Serialize(SerializeStream& stream, const void* otherObj
|
|||||||
SERIALIZE(InstanceToImportAs);
|
SERIALIZE(InstanceToImportAs);
|
||||||
SERIALIZE(ImportTextures);
|
SERIALIZE(ImportTextures);
|
||||||
SERIALIZE(RestoreMaterialsOnReimport);
|
SERIALIZE(RestoreMaterialsOnReimport);
|
||||||
|
SERIALIZE(SkipExistingMaterialsOnReimport);
|
||||||
SERIALIZE(GenerateSDF);
|
SERIALIZE(GenerateSDF);
|
||||||
SERIALIZE(SDFResolution);
|
SERIALIZE(SDFResolution);
|
||||||
SERIALIZE(SplitObjects);
|
SERIALIZE(SplitObjects);
|
||||||
@@ -422,6 +423,7 @@ void ModelTool::Options::Deserialize(DeserializeStream& stream, ISerializeModifi
|
|||||||
DESERIALIZE(InstanceToImportAs);
|
DESERIALIZE(InstanceToImportAs);
|
||||||
DESERIALIZE(ImportTextures);
|
DESERIALIZE(ImportTextures);
|
||||||
DESERIALIZE(RestoreMaterialsOnReimport);
|
DESERIALIZE(RestoreMaterialsOnReimport);
|
||||||
|
DESERIALIZE(SkipExistingMaterialsOnReimport);
|
||||||
DESERIALIZE(GenerateSDF);
|
DESERIALIZE(GenerateSDF);
|
||||||
DESERIALIZE(SDFResolution);
|
DESERIALIZE(SDFResolution);
|
||||||
DESERIALIZE(SplitObjects);
|
DESERIALIZE(SplitObjects);
|
||||||
@@ -1154,6 +1156,18 @@ bool ModelTool::ImportModel(const String& path, ModelData& data, Options& option
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip any materials that already exist from the model.
|
||||||
|
// This allows the use of "import as material instances" without material properties getting overridden on each import.
|
||||||
|
if (options.SkipExistingMaterialsOnReimport)
|
||||||
|
{
|
||||||
|
AssetInfo info;
|
||||||
|
if (Content::GetAssetInfo(assetPath, info))
|
||||||
|
{
|
||||||
|
material.AssetID = info.ID;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options.ImportMaterialsAsInstances)
|
if (options.ImportMaterialsAsInstances)
|
||||||
{
|
{
|
||||||
// Create material instance
|
// Create material instance
|
||||||
|
|||||||
@@ -268,9 +268,12 @@ public:
|
|||||||
// If checked, the importer will import texture files used by the model and any embedded texture resources.
|
// If checked, the importer will import texture files used by the model and any embedded texture resources.
|
||||||
API_FIELD(Attributes="EditorOrder(410), EditorDisplay(\"Materials\"), VisibleIf(nameof(ShowGeometry))")
|
API_FIELD(Attributes="EditorOrder(410), EditorDisplay(\"Materials\"), VisibleIf(nameof(ShowGeometry))")
|
||||||
bool ImportTextures = true;
|
bool ImportTextures = true;
|
||||||
// If checked, the importer will try to keep the model's current material slots, instead of importing materials from the source file.
|
// If checked, the importer will try to keep the model's current overridden material slots, instead of importing materials from the source file.
|
||||||
API_FIELD(Attributes="EditorOrder(420), EditorDisplay(\"Materials\", \"Keep Material Slots on Reimport\"), VisibleIf(nameof(ShowGeometry))")
|
API_FIELD(Attributes="EditorOrder(420), EditorDisplay(\"Materials\", \"Keep Overridden Materials\"), VisibleIf(nameof(ShowGeometry))")
|
||||||
bool RestoreMaterialsOnReimport = true;
|
bool RestoreMaterialsOnReimport = true;
|
||||||
|
// If checked, the importer will not reimport any material from this model which already exist in the sub-asset folder.
|
||||||
|
API_FIELD(Attributes = "EditorOrder(421), EditorDisplay(\"Materials\", \"Skip Existing Materials\"), VisibleIf(nameof(ShowGeometry))")
|
||||||
|
bool SkipExistingMaterialsOnReimport = true;
|
||||||
|
|
||||||
public: // SDF
|
public: // SDF
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user