Fix remaining voxel references in Game.

This commit is contained in:
Paul Chote
2017-06-09 09:27:35 +01:00
committed by reaperrr
parent 6ca0208694
commit 2683b2507e
2 changed files with 15 additions and 15 deletions

View File

@@ -79,7 +79,7 @@ namespace OpenRA.Graphics
}
public ModelRenderProxy RenderAsync(
WorldRenderer wr, IEnumerable<ModelAnimation> voxels, WRot camera, float scale,
WorldRenderer wr, IEnumerable<ModelAnimation> models, WRot camera, float scale,
float[] groundNormal, WRot lightSource, float[] lightAmbientColor, float[] lightDiffuseColor,
PaletteReference color, PaletteReference normals, PaletteReference shadowPalette)
{
@@ -105,18 +105,18 @@ namespace OpenRA.Graphics
var stl = new float2(float.MaxValue, float.MaxValue);
var sbr = new float2(float.MinValue, float.MinValue);
foreach (var v in voxels)
foreach (var m in models)
{
// Convert screen offset back to world coords
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(v.OffsetFunc()));
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(m.OffsetFunc()));
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
var worldTransform = v.RotationFunc().Aggregate(Util.IdentityMatrix(),
var worldTransform = m.RotationFunc().Aggregate(Util.IdentityMatrix(),
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
worldTransform = Util.MatrixMultiply(scaleTransform, worldTransform);
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
var bounds = v.Model.Bounds(v.FrameFunc());
var bounds = m.Model.Bounds(m.FrameFunc());
var worldBounds = Util.MatrixAABBMultiply(worldTransform, bounds);
var screenBounds = Util.MatrixAABBMultiply(cameraTransform, worldBounds);
var shadowBounds = Util.MatrixAABBMultiply(shadowTransform, worldBounds);
@@ -177,13 +177,13 @@ namespace OpenRA.Graphics
doRender.Add(Pair.New<Sheet, Action>(sprite.Sheet, () =>
{
foreach (var v in voxels)
foreach (var m in models)
{
// Convert screen offset to world offset
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(v.OffsetFunc()));
var offsetVec = Util.MatrixVectorMultiply(invCameraTransform, wr.ScreenVector(m.OffsetFunc()));
var offsetTransform = Util.TranslationMatrix(offsetVec[0], offsetVec[1], offsetVec[2]);
var rotations = v.RotationFunc().Aggregate(Util.IdentityMatrix(),
var rotations = m.RotationFunc().Aggregate(Util.IdentityMatrix(),
(x, y) => Util.MatrixMultiply(Util.MakeFloatMatrix(y.AsMatrix()), x));
var worldTransform = Util.MatrixMultiply(scaleTransform, rotations);
worldTransform = Util.MatrixMultiply(offsetTransform, worldTransform);
@@ -196,11 +196,11 @@ namespace OpenRA.Graphics
var lightTransform = Util.MatrixMultiply(Util.MatrixInverse(rotations), invShadowTransform);
var frame = v.FrameFunc();
for (uint i = 0; i < v.Model.Sections; i++)
var frame = m.FrameFunc();
for (uint i = 0; i < m.Model.Sections; i++)
{
var rd = v.Model.RenderData(i);
var t = v.Model.TransformationMatrix(i, frame);
var rd = m.Model.RenderData(i);
var t = m.Model.TransformationMatrix(i, frame);
var it = Util.MatrixInverse(t);
if (it == null)
throw new InvalidOperationException("Failed to invert the transformed matrix of frame {0} during RenderAsync.".F(i));
@@ -212,7 +212,7 @@ namespace OpenRA.Graphics
lightAmbientColor, lightDiffuseColor, color.TextureMidIndex, normals.TextureMidIndex);
// Disable shadow normals by forcing zero diffuse and identity ambient light
if (v.ShowShadow)
if (m.ShowShadow)
Render(rd, wr.World.ModelCache, Util.MatrixMultiply(shadow, t), lightDirection,
ShadowAmbient, ShadowDiffuse, shadowPalette.TextureMidIndex, normals.TextureMidIndex);
}

View File

@@ -241,7 +241,7 @@ namespace OpenRA.Graphics
return new float3((float)Math.Round(px.X), (float)Math.Round(px.Y), px.Z);
}
// For scaling vectors to pixel sizes in the voxel renderer
// For scaling vectors to pixel sizes in the model renderer
public float3 ScreenVectorComponents(WVec vec)
{
return new float3(
@@ -250,7 +250,7 @@ namespace OpenRA.Graphics
(float)TileSize.Height * vec.Z / TileScale);
}
// For scaling vectors to pixel sizes in the voxel renderer
// For scaling vectors to pixel sizes in the model renderer
public float[] ScreenVector(WVec vec)
{
var xyz = ScreenVectorComponents(vec);