Skip to content

Commit

Permalink
Release/v3.0.1 (Synesthesias#304)
Browse files Browse the repository at this point in the history
* アンケートのURLを変更しました

* LandscapeDesignToolに対応するためアクセス修飾子を変更 (Synesthesias#300)

Co-authored-by: matsunaga0910 <[email protected]>

* 高さ合わせやAssetsに保存機能について、処理前後で属性情報やマテリアルが維持されないことがあるバグを修正 (Synesthesias#302)

モデル調整で同名のゲームオブジェクトがある場合に対応中

「Assetsに保存」で同名のgmlファイルがあると情報が維持されない問題を修正

微修正

同上

* dllをリリースビルドに

* package.json更新

---------

Co-authored-by: SYN-miyamoto <[email protected]>
Co-authored-by: matsunaga0910 <[email protected]>
Co-authored-by: matsunaga0910 <[email protected]>
Co-authored-by: Linoal <[email protected]>
  • Loading branch information
5 people authored Aug 26, 2024
1 parent 5840475 commit 104dade
Show file tree
Hide file tree
Showing 38 changed files with 268 additions and 185 deletions.
4 changes: 2 additions & 2 deletions Plugins/Android/libplateau.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/Linux/x86_64/libplateau.so
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libOpenMeshCore.8.0.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libOpenMeshCore.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libOpenMeshTools.8.0.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libOpenMeshTools.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libplateau.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libz.1.2.13.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libz.1.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/arm64/libz.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libOpenMeshCore.8.0.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libOpenMeshCore.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libOpenMeshTools.8.0.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libOpenMeshTools.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libplateau.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libz.1.2.13.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libz.1.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/MacOS/x86_64/libz.dylib
Git LFS file not shown
4 changes: 2 additions & 2 deletions Plugins/Windows/x86_64/plateau.dll
Git LFS file not shown
Binary file modified Plugins/iOS/plateau.framework/plateau
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ PLATEAU SDK for Unityを利用することで、実世界を舞台にしたア

◆PLATEAU SDK for Unityは利用者アンケートを実施しています。
今後の開発の参考にするため、ユーザーの皆様の忌憚ないご意見をお聞かせください。
[アンケートはこちら](https://docs.google.com/forms/d/e/1FAIpQLSeICxDJd6eQ311_rDbCudc2c8UUZ8A0oE6LXppKoHgT2mwYQQ/viewform)
[アンケートはこちら](https://docs.google.com/forms/d/e/1FAIpQLSeqq0pm7UM7Rr-UgIHYT-D52jC08IjUG8auoqXTDvaee5YFxw/viewform)

◆PLATEAU SLackコミュニティはどなたでもご参加いただけます。
参加希望の方は、[お問い合わせページ](https://www.mlit.go.jp/plateau/contact/)よりお気軽にお問い合わせください。
Expand Down
27 changes: 15 additions & 12 deletions Runtime/CityAdjust/AlignLand/AlignLandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task ExecAsync(ALConfig conf, IProgressDisplay progressDisplay)
new NameToAttrsDict(),
new ContourMeshesMaker()
);
nonLibDataHolder.ComposeFrom(alignTarget);
nonLibDataHolder.ComposeFrom(new []{alignTarget, alignInvertTarget});

// 土地の高さをC++に送ります。
using var heightmapAligner = HeightMapAligner.Create(HeightOffset, CoordinateSystem.EUN);
Expand All @@ -104,7 +104,7 @@ public async Task ExecAsync(ALConfig conf, IProgressDisplay progressDisplay)
}


var sumResult = new GranularityConvertResult();
var resultTransforms = new UniqueParentTransformList();
var alTargets = alignTarget.Get.ToArray();
var alignTargetModels = new Model[alTargets.Length];
var subMeshConverters = new GameMaterialIDRegistry[alTargets.Length];
Expand Down Expand Up @@ -173,6 +173,7 @@ public async Task ExecAsync(ALConfig conf, IProgressDisplay progressDisplay)
var terrainData = terrain.terrainData;
var heightmap2d = HeightmapGenerator.ConvertTo2DFloatArray(heightmap1d, terrainData.heightmapResolution, terrainData.heightmapResolution);
terrain.terrainData.SetHeights(0, 0, heightmap2d);
resultTransforms.Add(land);
}
}

Expand Down Expand Up @@ -205,26 +206,28 @@ public async Task ExecAsync(ALConfig conf, IProgressDisplay progressDisplay)
r.parent = target.parent;
}

sumResult.Merge(result);
resultTransforms.AddRange(result.GeneratedRootTransforms.Get);
}

if (conf.DoDestroySrcObj)
{
foreach (var src in alignTarget.Get)
{
Object.DestroyImmediate(src.gameObject);
}
}
}


// 変換前の情報を復元します。
nonLibDataHolder.RestoreTo(sumResult.GeneratedRootTransforms);
nonLibDataHolder.RestoreTo(resultTransforms);

// 復元後に元のオブジェクトを削除します。
if (conf.AlignLandNormal && conf.DoDestroySrcObj)
{
foreach (var src in alignTarget.Get)
{
Object.DestroyImmediate(src.gameObject);
}
}


#if UNITY_EDITOR
var selected = Selection.objects.ToList();
selected.AddRange(sumResult.GeneratedRootTransforms.Get.Select(trans => trans.gameObject).Cast<Object>());
selected.AddRange(resultTransforms.Get.Select(trans => trans.gameObject).Cast<Object>());
Selection.objects = selected.ToArray();
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#endif
Expand Down
16 changes: 16 additions & 0 deletions Runtime/CityAdjust/ConvertToAsset/ConvertToAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using PLATEAU.Geometries;
using PLATEAU.Util;
using System.Linq;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;
Expand Down Expand Up @@ -108,6 +109,7 @@ public void Convert(ConvertToAssetConfig conf)
if (srcObj == null) continue;
var newObj = Object.Instantiate(srcObj, srcTrans.position, srcTrans.rotation, dstParent);
newObj.name = srcObj.name;
AdjustGameObjectNames(newObj.transform);
newTransforms.Add(newObj.transform);
}

Expand Down Expand Up @@ -166,5 +168,19 @@ private static void AdjustFbxImportSettings(string targetFolderPath)
throw new NotImplementedException("ConvertToAssetはランタイムでの実行には未対応です。");
#endif
}

private void AdjustGameObjectNames(Transform target)
{
new UniqueParentTransformList(target).BfsExec(trans =>
{
// 同名のgmlがあるとき、FBXにすると "xxx.gml 1" のように末尾に数字が付いてしまうのを修正します。
if (Regex.IsMatch(trans.name, @"^.+\.gml\s[0-9]+$"))
{
trans.name = Regex.Replace(trans.name, @"\.gml\s[0-9]+$", ".gml");
}

return NextSearchFlow.Continue;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PLATEAU.CityAdjust.MaterialAdjust.ExecutorV2
{
internal interface IMAExecutorV2
public interface IMAExecutorV2
{
public Task<UniqueParentTransformList> ExecAsync(MAExecutorConf conf);
}
Expand Down
2 changes: 1 addition & 1 deletion Runtime/CityAdjust/MaterialAdjust/Searcher/SearchArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace PLATEAU.CityAdjust.MaterialAdjust
/// <summary>
/// マテリアル分けのキーを検索するための条件です。
/// </summary>
internal class SearchArg
public class SearchArg
{
public SearchArg(UniqueParentTransformList targetTransforms)
{
Expand Down
2 changes: 1 addition & 1 deletion Runtime/CityAdjust/MaterialAdjust/Searcher/TypeSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace PLATEAU.CityAdjust.MaterialAdjust
/// <summary>
/// 地物型を基準にマテリアル分けのキーを検索します。
/// </summary>
internal class TypeSearcher : ISearcher<CityObjectTypeHierarchy.Node>
public class TypeSearcher : ISearcher<CityObjectTypeHierarchy.Node>
{
private SearchArg searchArg;

Expand Down
17 changes: 5 additions & 12 deletions Runtime/CityAdjust/NonLibData/ContourMeshesMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace PLATEAU.CityAdjust.NonLibData
internal class ContourMeshesMaker : INonLibData
{
// 記録用の辞書であり、Valueは頂点座標です。
private Dictionary<NonLibKeyName, ContourMesh> data = new();
private NonLibDictionary<ContourMesh> data = new();

/// <summary> 道路の頂点を記憶します。 </summary>
public void ComposeFrom(UniqueParentTransformList src)
Expand All @@ -24,11 +24,7 @@ public void ComposeFrom(UniqueParentTransformList src)
var contour = trans.GetComponent<PLATEAUContourMesh>();
if (contour != null)
{
var contourKey = new NonLibKeyName(trans, src.Get.ToArray());
if (!data.TryAdd(contourKey, contour.contourMesh))
{
Debug.Log($"key {contourKey} is already exists.");
}
data.Add(trans, src.Get.ToArray(), contour.contourMesh);
return NextSearchFlow.Continue;
}
var cog = trans.GetComponent<PLATEAUCityObjectGroup>();
Expand All @@ -38,11 +34,7 @@ public void ComposeFrom(UniqueParentTransformList src)
if (mf == null) return NextSearchFlow.Continue;
var mesh = mf.sharedMesh;
if (mesh == null) return NextSearchFlow.Continue;
var key = new NonLibKeyName(trans, src.Get.ToArray());
if (!data.TryAdd(key, new ContourMesh(mesh.vertices, mesh.triangles)))
{
Debug.Log($"key {key} is already exists.");
}
data.Add(trans, src.Get.ToArray(), new ContourMesh(mesh.vertices, mesh.triangles));

return NextSearchFlow.Continue;
});
Expand All @@ -53,7 +45,8 @@ public void RestoreTo(UniqueParentTransformList target)
{
target.BfsExec(trans =>
{
if (data.TryGetValue(new NonLibKeyName(trans, target.Get.ToArray()), out var vertices))
var vertices = data.GetNonRestoredAndMarkRestored(trans, target.Get.ToArray());
if (vertices != null)
{
var contour = trans.gameObject.AddComponent<PLATEAUContourMesh>();
contour.Init(vertices);
Expand Down
15 changes: 6 additions & 9 deletions Runtime/CityAdjust/NonLibData/InstancedCityModelDict.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class InstancedCityModelDict : INonLibData
/// <summary>
/// ゲームオブジェクト名とPLATEAUInstancedCityModelを紐つけます。
/// </summary>
private Dictionary<NonLibKeyName, PLATEAUInstancedCityModel> data = new();
private NonLibDictionary<PLATEAUInstancedCityModel> data = new();

/// <summary>
/// <paramref name="srcGameObjs"/> とその子に含まれる<see cref="PLATEAUInstancedCityModel"/>を
Expand All @@ -27,8 +27,7 @@ public void ComposeFrom(UniqueParentTransformList srcTransforms)
trans =>
{
var cityModel = trans.GetComponent<PLATEAUInstancedCityModel>();
if (cityModel == null) return NextSearchFlow.Continue;
data.Add(new NonLibKeyName(trans, srcTransforms.Get.ToArray()), cityModel);
data.Add(trans, srcTransforms.Get.ToArray(), cityModel); // cityModelがnullでも登録します。
return NextSearchFlow.Continue;
});
}
Expand All @@ -39,16 +38,14 @@ public void ComposeFrom(UniqueParentTransformList srcTransforms)
/// </summary>
public void RestoreTo(UniqueParentTransformList rootTransforms)
{
var remaining = new Dictionary<NonLibKeyName, PLATEAUInstancedCityModel>(data);
rootTransforms.BfsExec(
trans =>
{
var key = new NonLibKeyName(trans, rootTransforms.Get.ToArray());
if (!remaining.ContainsKey(key)) return NextSearchFlow.Continue;
var srcModel = data.GetNonRestoredAndMarkRestored(trans, rootTransforms.Get.ToArray());
if (srcModel == null) return NextSearchFlow.Continue;
var newModel = trans.gameObject.AddComponent<PLATEAUInstancedCityModel>();
newModel.CopyFrom(remaining[key]);
remaining.Remove(key);
if (remaining.Count == 0) return NextSearchFlow.Abort;
newModel.CopyFrom(srcModel);
if (data.RemainingNonRestored == 0) return NextSearchFlow.Abort;
return NextSearchFlow.Continue;
});

Expand Down
17 changes: 8 additions & 9 deletions Runtime/CityAdjust/NonLibData/NameToAttrsDict.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ namespace PLATEAU.CityAdjust.NonLibData
/// </summary>
internal class NameToAttrsDict : INonLibData
{
private Dictionary<NonLibKeyName, PLATEAUCityObjectGroup> data = new();
private NonLibDictionary<PLATEAUCityObjectGroup> data = new();

/// <summary>
/// ゲームオブジェクトとその子から属性情報の辞書を構築します。
/// </summary>
public void ComposeFrom(UniqueParentTransformList src)
{
var attrs =
src.Get.SelectMany(trans => trans.GetComponentsInChildren<PLATEAUCityObjectGroup>());
foreach (var attr in attrs)
src.BfsExec(trans =>
{
data.TryAdd(new NonLibKeyName(attr.transform, src.Get.ToArray()), attr);
}
var cog = trans.GetComponent<PLATEAUCityObjectGroup>();
data.Add(trans, src.Get.ToArray(), cog); // nullでも追加します。
return NextSearchFlow.Continue;
});
}

/// <summary>
Expand All @@ -34,15 +34,14 @@ public void RestoreTo(UniqueParentTransformList target)
{
target.BfsExec(trans =>
{
var key = new NonLibKeyName(trans, target.Get.ToArray());
if (!data.ContainsKey(key)) return NextSearchFlow.Continue;
var srcAttr = data.GetNonRestoredAndMarkRestored(trans, target.Get.ToArray());
if (srcAttr == null) return NextSearchFlow.Continue;
var dstAttr = trans.GetComponent<PLATEAUCityObjectGroup>();
if (dstAttr == null)
{
dstAttr = trans.gameObject.AddComponent<PLATEAUCityObjectGroup>();
}

var srcAttr = data[key];
dstAttr.Init(srcAttr.CityObjects, srcAttr.InfoForToolkits, srcAttr.Granularity, srcAttr.Lod);

return NextSearchFlow.Continue;
Expand Down
Loading

0 comments on commit 104dade

Please sign in to comment.