[Vala] 2D Static Array



Hallo.
I'm trying to convert my 2D matrix utility functions to use vala.

In C I have a struct containing a 2D static array rappresenting the matrix:

typedef struct _Matrix Matrix;
struct _Matrix
{
   float mat[4][4];
}

Converting in vala, it becomes:

[Compact]
public class Matrix
{
    public float mat[4,4];
}

But compiler doesn't support multi dimensional embedded array!!

If I write in the following way it embeds correctly the mono dimensional
array:

Compact]
public class Matrix
{
    public float mat[16];
}

But it is not what I whant.

Eventually I can add inline getteres and setters:

[Compact]
public class Matrix
{
    public float mat[16];

    public inline float get(int row, int col)
    {
        return mat[row*4 + col];
    }

    public inline void set(int row, int col, float val)
    {
        mat[row*4 + col] = val;
    }
}

But compiling with vala -C, I see that inline doesn't do nothing!!

Thik about  matrix calculation in a 3D application:
if to read or update a value in a matrix I have to call functions,
calculations slow down to much!!

What can I do?

P.S. sorry for my bad english...

  Michele


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]