Skip to content

Commit

Permalink
add a check if tags column is null or not
Browse files Browse the repository at this point in the history
  • Loading branch information
bertt committed Oct 16, 2024
1 parent a0cb718 commit 1b53fe9
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/GPUTileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using SharpGLTF.Schema2;
using SharpGLTF.Schema2.Tiles3D;
using SharpGLTF.Transforms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
Expand All @@ -26,19 +25,24 @@ public static byte[] GetGPUTile(List<Instance> instances, bool UseScaleNonUnifor
settings.GpuMeshInstancingMinCount = 0;
var model = sceneBuilder.ToGltf2(settings);

var schema = AddMetadataSchema(model);

var distinctModels = instances.Select(s => s.Model).Distinct();
// check if one of the instances has tags
if (instances.Any(s => s.Tags != null))
{
var schema = AddMetadataSchema(model);

var i = 0;
var distinctModels = instances.Select(s => s.Model).Distinct();

foreach (var distinctModel in distinctModels)
{
var modelInstances = instances.Where(s => s.Model.Equals(distinctModel)).ToList();
var featureIdBuilder = GetFeatureIdBuilder(schema, modelInstances);
var node = model.LogicalNodes[i];
node.AddInstanceFeatureIds(featureIdBuilder);
i++;
var i = 0;

foreach (var distinctModel in distinctModels)
{
var modelInstances = instances.Where(s => s.Model.Equals(distinctModel)).ToList();
var featureIdBuilder = GetFeatureIdBuilder(schema, modelInstances);
var node = model.LogicalNodes[i];
node.AddInstanceFeatureIds(featureIdBuilder);
i++;
}
}

foreach (var node in model.LogicalNodes)
Expand Down

0 comments on commit 1b53fe9

Please sign in to comment.