From 9c9a23be86d4b9e898097ed12d3c5a248073ff8c Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 11 Jun 2017 18:32:14 +0100 Subject: [PATCH] Make Frames and Limbs private. --- OpenRA.Mods.Cnc/Graphics/Voxel.cs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/OpenRA.Mods.Cnc/Graphics/Voxel.cs b/OpenRA.Mods.Cnc/Graphics/Voxel.cs index 1c4b35a1ba..14e2d98f43 100644 --- a/OpenRA.Mods.Cnc/Graphics/Voxel.cs +++ b/OpenRA.Mods.Cnc/Graphics/Voxel.cs @@ -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[]