Skip to content

Commit

Permalink
Merge pull request #82 from Geodan/improve_height_precision
Browse files Browse the repository at this point in the history
update verticals
  • Loading branch information
bertt authored Oct 22, 2024
2 parents 636cad8 + 20a0fb3 commit 28a55fd
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/GPUTileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static byte[] GetGPUTile(List<Instance> instances, bool UseScaleNonUnifor

foreach (var node in model.LogicalNodes)
{
node.LocalTransform *= Matrix4x4.CreateTranslation(translation);
var tra = new Vector3((float)translation.X, (float)translation.Y, (float)translation.Z);
node.LocalTransform *= Matrix4x4.CreateTranslation(tra);
}

var bytes = model.WriteGLB().Array;
Expand All @@ -73,7 +74,7 @@ private static StructuralMetadataClass AddMetadataSchema(ModelRoot gltf)
return schemaClass;
}

private static SceneBuilder AddModels(IEnumerable<Instance> instances, Vector3 translation, bool UseScaleNonUniform)
private static SceneBuilder AddModels(IEnumerable<Instance> instances, Point translation, bool UseScaleNonUniform)
{
var sceneBuilder = new SceneBuilder();

Expand All @@ -88,7 +89,7 @@ private static SceneBuilder AddModels(IEnumerable<Instance> instances, Vector3 t
return sceneBuilder;
}

private static void AddModelInstancesToScene(SceneBuilder sceneBuilder, IEnumerable<Instance> instances, bool UseScaleNonUniform, Vector3 translation, string model)
private static void AddModelInstancesToScene(SceneBuilder sceneBuilder, IEnumerable<Instance> instances, bool UseScaleNonUniform, Point translation, string model)
{
var modelInstances = instances.Where(s => s.Model.Equals(model)).ToList();
var modelRoot = ModelRoot.Load(model);
Expand All @@ -103,7 +104,7 @@ private static void AddModelInstancesToScene(SceneBuilder sceneBuilder, IEnumera
}
}

private static SceneBuilder GetSceneBuilder(IMeshBuilder<MaterialBuilder> meshBuilder, Instance instance, bool UseScaleNonUniform, Vector3 translation, int pointId)
private static SceneBuilder GetSceneBuilder(IMeshBuilder<MaterialBuilder> meshBuilder, Instance instance, bool UseScaleNonUniform, Point translation, int pointId)
{
var transformation = GetInstanceTransform(instance, UseScaleNonUniform, translation);
var json = "{\"_FEATURE_ID_0\":" + pointId + "}";
Expand All @@ -112,7 +113,7 @@ private static SceneBuilder GetSceneBuilder(IMeshBuilder<MaterialBuilder> meshBu
return sceneBuilder;
}

private static AffineTransform GetInstanceTransform(Instance instance, bool UseScaleNonUniform, Vector3 translation)
private static AffineTransform GetInstanceTransform(Instance instance, bool UseScaleNonUniform, Point translation)
{
var point = (Point)instance.Position;

Expand All @@ -126,7 +127,7 @@ private static AffineTransform GetInstanceTransform(Instance instance, bool UseS
var instanceQuaternion = Quaternion.CreateFromYawPitchRoll((float)instance.Yaw, (float)instance.Pitch, (float)instance.Roll);
var res = Quaternion.CreateFromRotationMatrix(m4);

var position2 = position - translation;
var position2 = new Vector3((float)(position.X - translation.X), (float)(position.Y - translation.Y), (float)(position.Z - translation.Z));

var scale = UseScaleNonUniform ?
new Vector3((float)instance.ScaleNonUniform[0], (float)instance.ScaleNonUniform[1], (float)instance.ScaleNonUniform[2]) :
Expand Down Expand Up @@ -199,8 +200,8 @@ private static Matrix4x4 GetTransformationMatrix((Vector3 East, Vector3 North, V
m4.M33 = forward.Z;
return m4;
}
private static Vector3 ToYUp(Point position)
private static Point ToYUp(Point position)
{
return new Vector3((float)position.X, (float)position.Z, (float)position.Y * -1);
return new Point((double)position.X, (double)position.Z, (double)position.Y * -1);
}
}

0 comments on commit 28a55fd

Please sign in to comment.