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