Make Frames and Limbs private.

This commit is contained in:
Paul Chote
2017-06-11 18:32:14 +01:00
committed by reaperrr
parent 2683b2507e
commit 9c9a23be86

View File

@@ -26,14 +26,13 @@ namespace OpenRA.Mods.Cnc.Graphics
public class Voxel : IModel
{
Limb[] limbData;
float[] transforms;
readonly Limb[] limbData;
readonly float[] transforms;
readonly uint frames;
readonly uint limbs;
public readonly uint Frames;
public readonly uint Limbs;
uint IModel.Frames { get { return Frames; } }
uint IModel.Sections { get { return Limbs; } }
uint IModel.Frames { get { return frames; } }
uint IModel.Sections { get { return limbs; } }
public Voxel(VoxelLoader loader, VxlReader vxl, HvaReader hva)
{
@@ -41,8 +40,8 @@ namespace OpenRA.Mods.Cnc.Graphics
throw new InvalidOperationException("Voxel and hva limb counts don't match");
transforms = hva.Transforms;
Frames = hva.FrameCount;
Limbs = hva.LimbCount;
frames = hva.FrameCount;
limbs = hva.LimbCount;
limbData = new Limb[vxl.LimbCount];
for (var i = 0; i < vxl.LimbCount; i++)
@@ -59,14 +58,14 @@ namespace OpenRA.Mods.Cnc.Graphics
public float[] TransformationMatrix(uint limb, uint frame)
{
if (frame >= Frames)
throw new ArgumentOutOfRangeException("frame", "Only {0} frames exist.".F(Frames));
if (limb >= Limbs)
throw new ArgumentOutOfRangeException("limb", "Only {1} limbs exist.".F(Limbs));
if (frame >= frames)
throw new ArgumentOutOfRangeException("frame", "Only {0} frames exist.".F(frames));
if (limb >= limbs)
throw new ArgumentOutOfRangeException("limb", "Only {1} limbs exist.".F(limbs));
var l = limbData[limb];
var t = new float[16];
Array.Copy(transforms, 16 * (Limbs * frame + limb), t, 0, 16);
Array.Copy(transforms, 16 * (limbs * frame + limb), t, 0, 16);
// Fix limb position
t[12] *= l.Scale * (l.Bounds[3] - l.Bounds[0]) / l.Size[0];
@@ -104,7 +103,7 @@ namespace OpenRA.Mods.Cnc.Graphics
var ret = new float[] { float.MaxValue, float.MaxValue, float.MaxValue,
float.MinValue, float.MinValue, float.MinValue };
for (uint j = 0; j < Limbs; j++)
for (uint j = 0; j < limbs; j++)
{
var l = limbData[j];
var b = new float[]