Skip to content

Commit

Permalink
fix RenderingAsset::Relocate (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBelousov authored Feb 15, 2023
1 parent 886458a commit 38a72ad
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions iModelCore/iModelPlatform/DgnCore/RenderMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,24 @@ void RenderingAsset::SetColor(Utf8CP keyword, RgbFactor color)
BentleyStatus RenderingAsset::Relocate(DgnImportContext& context)
{
auto patternMap = GetPatternMap();
// ###TODO why is this an error? A pattern map is not required.
if (!patternMap.IsValid())
return ERROR;
auto normalMap = GetNormalMap();

DgnTextureId newId = patternMap.Relocate(context);
if (!newId.IsValid())
return ERROR;
if (patternMap.IsValid())
{
DgnTextureId newId = patternMap.Relocate(context);
if (!newId.IsValid())
return ERROR;
GetValueR(RENDER_MATERIAL_Map)[RENDER_MATERIAL_MAP_Pattern][RENDER_MATERIAL_TextureId] = newId.ToHexStr();
}

// ###TODO this writes to the wrong JSON property. Should be Map.Pattern.TextureId
GetValueR(RENDER_MATERIAL_Map)[RENDER_MATERIAL_TextureId] = newId.ToHexStr();
if (normalMap.IsValid())
{
DgnTextureId newId = normalMap.Relocate(context);
if (!newId.IsValid())
return ERROR;
GetValueR(RENDER_MATERIAL_Map)[RENDER_MATERIAL_MAP_Normal][RENDER_MATERIAL_TextureId] = newId.ToHexStr();
}

// ###TODO relocate other maps, such as Normal.
return SUCCESS;
}

Expand Down

0 comments on commit 38a72ad

Please sign in to comment.