Use a constant inverse scale when converting to godot vec3
This commit is contained in:
parent
d7b8ee35f4
commit
50c4d06f19
|
@ -5,8 +5,9 @@ namespace KeepersCompound.LGS;
|
|||
|
||||
public static class Utils
|
||||
{
|
||||
public static Godot.Vector3 ToGodotVec3(this Vector3 vec, float inverseScale)
|
||||
const float InverseScale = 4.0f;
|
||||
public static Godot.Vector3 ToGodotVec3(this Vector3 vec)
|
||||
{
|
||||
return new Godot.Vector3(vec.Y, vec.Z, vec.X) / inverseScale;
|
||||
return new Godot.Vector3(vec.Y, vec.Z, vec.X) / InverseScale;
|
||||
}
|
||||
}
|
|
@ -103,12 +103,12 @@ public partial class Mission : Node3D
|
|||
var poly = cell.Polys[i];
|
||||
var meshIdxOffset = vertices.Count;
|
||||
|
||||
var normal = cell.Planes[poly.PlaneId].Normal.ToGodotVec3(4.0f);
|
||||
var normal = cell.Planes[poly.PlaneId].Normal.ToGodotVec3();
|
||||
var numPolyVertices = poly.VertexCount;
|
||||
for (var j = 0; j < numPolyVertices; j++)
|
||||
{
|
||||
var vertex = cell.Vertices[cell.Indices[cellIdxOffset + j]];
|
||||
vertices.Add(vertex.ToGodotVec3(4.0f));
|
||||
vertices.Add(vertex.ToGodotVec3());
|
||||
normals.Add(normal);
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ public partial class Mission : Node3D
|
|||
{
|
||||
var light = new OmniLight3D
|
||||
{
|
||||
Position = cell.SphereCenter.ToGodotVec3(4.0f),
|
||||
Position = cell.SphereCenter.ToGodotVec3(),
|
||||
OmniRange = cell.SphereRadius * (r.NextSingle() + 1.0f) * 0.5f,
|
||||
};
|
||||
// cellNode.AddChild(light);
|
||||
|
@ -235,8 +235,8 @@ public partial class Mission : Node3D
|
|||
{
|
||||
// TODO: This is slightly hardcoded for ND. Check other stuff at some point. Should be handled in LG side imo
|
||||
// TODO: This is a mess lol
|
||||
var texU = renderPoly.TextureVectors.Item1.ToGodotVec3(4.0f);
|
||||
var texV = renderPoly.TextureVectors.Item2.ToGodotVec3(4.0f);
|
||||
var texU = renderPoly.TextureVectors.Item1.ToGodotVec3();
|
||||
var texV = renderPoly.TextureVectors.Item2.ToGodotVec3();
|
||||
|
||||
var uu = texU.Dot(texU);
|
||||
var vv = texV.Dot(texV);
|
||||
|
@ -248,7 +248,7 @@ public partial class Mission : Node3D
|
|||
var baseV = renderPoly.TextureBases.Item2;
|
||||
var lmUBase = lmUScale * (baseU + (0.5f - light.Bases.Item1) / 4.0f);
|
||||
var lmVBase = lmVScale * (baseV + (0.5f - light.Bases.Item2) / 4.0f);
|
||||
var anchor = cell.Vertices[cell.Indices[cellIdxOffset + 0]].ToGodotVec3(4.0f); // TODO: This probably shouldn't be hardcoded idx 0
|
||||
var anchor = cell.Vertices[cell.Indices[cellIdxOffset + 0]].ToGodotVec3(); // TODO: This probably shouldn't be hardcoded idx 0
|
||||
|
||||
var uvIdxs = new int[poly.VertexCount];
|
||||
if (uv == 0.0)
|
||||
|
@ -259,7 +259,7 @@ public partial class Mission : Node3D
|
|||
{
|
||||
uvIdxs[i] = lightmapUvs.Count;
|
||||
|
||||
var v = cell.Vertices[cell.Indices[cellIdxOffset + i]].ToGodotVec3(4.0f);
|
||||
var v = cell.Vertices[cell.Indices[cellIdxOffset + i]].ToGodotVec3();
|
||||
var delta = new Vector3(v.X - anchor.X, v.Y - anchor.Y, v.Z - anchor.Z);
|
||||
var lmUV = new Vector2(delta.Dot(lmUVec) + lmUBase, delta.Dot(lmVVec) + lmVBase);
|
||||
lightmapUvs.Add(lmUV);
|
||||
|
@ -276,7 +276,7 @@ public partial class Mission : Node3D
|
|||
{
|
||||
uvIdxs[i] = lightmapUvs.Count;
|
||||
|
||||
var v = cell.Vertices[cell.Indices[cellIdxOffset + i]].ToGodotVec3(4.0f);
|
||||
var v = cell.Vertices[cell.Indices[cellIdxOffset + i]].ToGodotVec3();
|
||||
var delta = new Vector3(v.X - anchor.X, v.Y - anchor.Y, v.Z - anchor.Z);
|
||||
var du = delta.Dot(texU);
|
||||
var dv = delta.Dot(texV);
|
||||
|
|
Loading…
Reference in New Issue