GMWolf
aka fel666
[edit] is this the right subforum? probably not...
GM at the moment is quite a mess with all the vector and matrix functions either taking in multiple float values, or returning arrays.
I suggest we get more functions to deal with vectors directly.
but first, some nice accessors to make everyone happy:
These should make working with vectors more pleasing to the eye
As for actual functions:
With these new functions, we could more easily reason about our code, no need to use many lines to de-array and re-array our vector variables.
Yes, these methods could be written in GML, but by having them be core functions, we can hopefully loose less performance when it comes to array accesses. very useful in vector heavy processes like procedural noise generation.
It would also be nice to extend these to colours:
GM at the moment is quite a mess with all the vector and matrix functions either taking in multiple float values, or returning arrays.
I suggest we get more functions to deal with vectors directly.
but first, some nice accessors to make everyone happy:
Code:
v.x //would be the same as v[0] if v is an array
v.y //same as v[1] if v is array
v.z //same as v[2] if v is array
v.w //same as v[2] if v is array
v.b //same as v.x
v.g //same as b.y
v.r //same as b.z
v.a //same as b.w
//bonus, combine them to get things like
v.xy //same as [v.x, v.y]
v.xz //same as [v.x, v.z]
//etc
As for actual functions:
Code:
vector_direction(array a, array b) //same as point direction, uses two array vectors
vector_distance(array a, array b) //same as point_distance, but with array vectors
vector_distance_3d(array a, array b) //again same as point_distance_3d
vector_dot_product(array a, array b) //same as dot_product, but with array vectors
(include all dot product normalized and 3d...)
matrix_transform_vector(matrix, vector) //same as matrix_transform_vertex, but with arrays
Yes, these methods could be written in GML, but by having them be core functions, we can hopefully loose less performance when it comes to array accesses. very useful in vector heavy processes like procedural noise generation.
It would also be nice to extend these to colours:
Code:
colour_get_vector(colour) //returns colour vector of color value, like color_get_rgb
colour_set_vector(vector) //get a colour value from the vector, like color_make_rgb