Time a bunch more stuff
This commit is contained in:
parent
72f8666f5d
commit
8237a46989
|
@ -245,7 +245,7 @@ public partial class Mission : Node3D
|
||||||
var rawRot = brush.angle;
|
var rawRot = brush.angle;
|
||||||
var rot = new Vector3(rawRot.Y, rawRot.Z, rawRot.X) * 360 / ushort.MaxValue;
|
var rot = new Vector3(rawRot.Y, rawRot.Z, rawRot.X) * 360 / ushort.MaxValue;
|
||||||
var scale = scaleProp == null ? Vector3.One : scaleProp.scale.ToGodotVec3(false);
|
var scale = scaleProp == null ? Vector3.One : scaleProp.scale.ToGodotVec3(false);
|
||||||
var model = _modelLoader.Load(_campaignName, modelName);
|
var model = Timing.TimeStage("Load Models", () => { return _modelLoader.Load(_campaignName, modelName); });
|
||||||
if (model != null)
|
if (model != null)
|
||||||
{
|
{
|
||||||
model.Position = pos;
|
model.Position = pos;
|
||||||
|
@ -394,28 +394,35 @@ public partial class Mission : Node3D
|
||||||
var layerCount = lightmap.Layers;
|
var layerCount = lightmap.Layers;
|
||||||
var srcRect = new Rect2I(0, 0, width, height);
|
var srcRect = new Rect2I(0, 0, width, height);
|
||||||
var dst = new Vector2I(rect.X, rect.Y);
|
var dst = new Vector2I(rect.X, rect.Y);
|
||||||
for (var i = 0; i < layerCount; i++)
|
Timing.TimeStage("Blit LM Data", () =>
|
||||||
{
|
{
|
||||||
var cellLm = Image.CreateFromData(width, height, false, lightmapFormat, lightmap.AsBytesRgba(i));
|
for (var i = 0; i < layerCount; i++)
|
||||||
lmImages[i].BlitRect(cellLm, srcRect, dst);
|
{
|
||||||
}
|
var bytes = Timing.TimeStage("Get LM Data", () => { return lightmap.AsBytesRgba(i); });
|
||||||
|
var cellLm = Image.CreateFromData(width, height, false, lightmapFormat, bytes);
|
||||||
|
lmImages[i].BlitRect(cellLm, srcRect, dst);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (!surfaceDataMap.ContainsKey(info.textureId)) GD.Print("Invalid SurfaceDataMap key");
|
Timing.TimeStage("Transform LM UVs", () =>
|
||||||
surfaceDataMap[info.textureId].TransformUv2s(info.uvStart, info.uvEnd, (uv) =>
|
|
||||||
{
|
{
|
||||||
var u = uv.X;
|
if (!surfaceDataMap.ContainsKey(info.textureId)) GD.Print("Invalid SurfaceDataMap key");
|
||||||
var v = uv.Y;
|
surfaceDataMap[info.textureId].TransformUv2s(info.uvStart, info.uvEnd, (uv) =>
|
||||||
|
{
|
||||||
|
var u = uv.X;
|
||||||
|
var v = uv.Y;
|
||||||
|
|
||||||
// Clamp uv range to [0..1]
|
// Clamp uv range to [0..1]
|
||||||
u %= 1;
|
u %= 1;
|
||||||
v %= 1;
|
v %= 1;
|
||||||
if (u < 0) u = Math.Abs(u);
|
if (u < 0) u = Math.Abs(u);
|
||||||
if (v < 0) v = Math.Abs(v);
|
if (v < 0) v = Math.Abs(v);
|
||||||
|
|
||||||
// Transform!
|
// Transform!
|
||||||
u = (rect.X + rect.Width * u) / bounds.Width;
|
u = (rect.X + rect.Width * u) / bounds.Width;
|
||||||
v = (rect.Y + rect.Height * v) / bounds.Height;
|
v = (rect.Y + rect.Height * v) / bounds.Height;
|
||||||
return new Vector2(u, v);
|
return new Vector2(u, v);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +445,7 @@ public partial class Mission : Node3D
|
||||||
// TODO: This is a mess lol
|
// TODO: This is a mess lol
|
||||||
var textureId = renderPoly.TextureId;
|
var textureId = renderPoly.TextureId;
|
||||||
|
|
||||||
var texture = _textureLoader.Get(textureId);
|
var texture = Timing.TimeStage("Load Textures", () => { return _textureLoader.Get(textureId); });
|
||||||
var texU = renderPoly.TextureVectors.Item1.ToGodotVec3();
|
var texU = renderPoly.TextureVectors.Item1.ToGodotVec3();
|
||||||
var texV = renderPoly.TextureVectors.Item2.ToGodotVec3();
|
var texV = renderPoly.TextureVectors.Item2.ToGodotVec3();
|
||||||
var baseU = renderPoly.TextureBases.Item1;
|
var baseU = renderPoly.TextureBases.Item1;
|
||||||
|
|
Loading…
Reference in New Issue