Okay, question time.
Here's the code for loading of a Table:
VALUE Table::rb_load(VALUE self, VALUE value)
{
// load Table size data
VALUE sliced_string = rb_str_substr(value, 0, 20);
VALUE data = rb_f_str_unpack(sliced_string, "LLLLL");
int dimensions = NUM2INT(rb_ary_shift(data));
VALUE rb_xSize = rb_ary_shift(data);
VALUE rb_ySize = rb_ary_shift(data);
VALUE rb_zSize = rb_ary_shift(data);
int size = NUM2INT(rb_xSize) * NUM2INT(rb_ySize) * NUM2INT(rb_zSize);
// create the table
VALUE argv[3] = {rb_xSize, rb_ySize, rb_zSize};
VALUE rb_table = Table::create(dimensions, argv);
RB_VAR2CPP(rb_table, Table, table);
// loading data entries
sliced_string = rb_str_substr(value, 20, size * 2);
data = rb_f_str_unpack(sliced_string, hstr('S', size).c_str());
for_iter (i, 0, size)
{
table->data[i] = (short)NUM2INT(rb_ary_shift(data));
}
return rb_table;
}
public static Table _arc_load(byte[] bytes)
{
int nx, ny, nz, dimensions, size;
dimensions = BitConverter.ToInt32(bytes, 0);
nx = BitConverter.ToInt32(bytes, 4);
ny = BitConverter.ToInt32(bytes, 8);
nz = BitConverter.ToInt32(bytes, 12);
size = nx * ny * nz;
Table table = new Table(nx, ny, nz);
int[] data = new int[size];
for (int i = 0; i < size; i++)
data[i] = BitConverter.ToInt16(bytes, 16 + (i * 2));
table._data = data;
table._dimensions = dimensions;
return table;
}
The C# implementation takes 16 bytes before reading data from the table.
- 1st 4: Dimension
- 2nd 4: X Size
- 3rd 4: Y Size
- 4th 4: Z Size
It then begins reading data using an offset of 16 bytes, to account for what is already been read.
I may just be misunderstanding the code a bit, but it appears the C++ (and Python) implementation reads 20 bytes.
- 1st 4: Dimension
- 2nd 4: X Size
- 3rd 4: Y Size
- 4th 4: Z Size
- 5th 4: ??????
It then begins with an offset of 20 bytes when reading the data. My question is: Am I misinterpreting the "rb_ary_shift(data)" and "rb_str_substr(value, 20, size * 2)" and what they do, or are there 4 unused bytes in there. What I don't understand is, if it is the latter, how do Tables load correctly at all? I realize it would really only mess up the first two loaded values in the table, but as far as I can see, they appear to be completely accurate to the original.
All the other possible faults with my serialization implementation aside, I am just not seeing why these damned Animations will not load. None of the _dump errors or mapping errors (which have been fixed) seem to have anything to do with the particular problem, unless I am mistaken.