Added helper functions for Vector3 and Vector2. Made them also use the functions themselves and fixed a small bug in Vector3 where only 2 values would be set and not all 3 when doing any kind of arithmetics on them.

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1672 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
groogy 2010-11-19 08:26:58 +00:00
parent 5161f2a4ee
commit 712b64d168
4 changed files with 148 additions and 80 deletions

View File

@ -25,6 +25,28 @@
VALUE globalVector2Class; VALUE globalVector2Class;
VALUE Vector2_GetX( VALUE self )
{
static ID idX = rb_intern( "x" );
return rb_funcall( self, idX, 0 );
}
VALUE Vector2_GetY( VALUE self )
{
static ID idY = rb_intern( "y" );
return rb_funcall( self, idY, 0 );
}
VALUE Vector2_SetX( VALUE self, VALUE aVal )
{
static ID idX = rb_intern( "x=" );
return rb_funcall( self, idX, 1, aVal );
}
VALUE Vector2_SetY( VALUE self, VALUE aVal )
{
static ID idY = rb_intern( "y=" );
return rb_funcall( self, idY, 1, aVal );
}
/* Internal function /* Internal function
* Forces the argument someValue to be a Vector2. IF it can convert it then it will. * Forces the argument someValue to be a Vector2. IF it can convert it then it will.
* So you can always safely asume that this function returns a Vector2 object. * So you can always safely asume that this function returns a Vector2 object.
@ -54,11 +76,11 @@ VALUE Vector2_ForceType( VALUE someValue )
static void Vector2_internal_CopyFrom( VALUE self, VALUE aSource ) static void Vector2_internal_CopyFrom( VALUE self, VALUE aSource )
{ {
VALUE vectorSource = Vector2_ForceType( aSource ); VALUE vectorSource = Vector2_ForceType( aSource );
VALUE x = rb_funcall( vectorSource, rb_intern( "x" ), 0 ); VALUE x = Vector2_GetX( self );
VALUE y = rb_funcall( vectorSource, rb_intern( "y" ), 0 ); VALUE y = Vector2_GetY( self );
rb_funcall( self, rb_intern( "x=" ), 1, x ); Vector2_SetX( self, x );
rb_funcall( self, rb_intern( "y=" ), 1, y ); Vector2_SetY( self, y );
rb_iv_set( self, "@dataType", rb_iv_get( vectorSource, "@dataType" ) ); rb_iv_set( self, "@dataType", rb_iv_get( vectorSource, "@dataType" ) );
} }
@ -81,8 +103,8 @@ static void Vector2_internal_ValidateTypes( VALUE aFirst, VALUE aSecond )
/* */ /* */
static VALUE Vector2_Negate( VALUE self ) static VALUE Vector2_Negate( VALUE self )
{ {
VALUE x = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE x = Vector2_GetX( self );
VALUE y = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE y = Vector2_GetY( self );
VALUE negatedX = rb_funcall( x, rb_intern( "-@" ), 0 ); VALUE negatedX = rb_funcall( x, rb_intern( "-@" ), 0 );
VALUE negatedY = rb_funcall( y, rb_intern( "-@" ), 0 ); VALUE negatedY = rb_funcall( y, rb_intern( "-@" ), 0 );
return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, negatedX, negatedY ); return rb_funcall( globalVector2Class, rb_intern( "new" ), 2, negatedX, negatedY );
@ -93,10 +115,10 @@ static VALUE Vector2_Add( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector2_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector2_GetY( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector2_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector2_GetY( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "+" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "+" ), 1, rightX );
@ -110,10 +132,10 @@ static VALUE Vector2_Subtract( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector2_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector2_GetY( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector2_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector2_GetY( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "-" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "-" ), 1, rightX );
@ -127,10 +149,10 @@ static VALUE Vector2_Multiply( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector2_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector2_GetY( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector2_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector2_GetY( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "*" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "*" ), 1, rightX );
@ -144,10 +166,10 @@ static VALUE Vector2_Divide( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector2_ForceType( aRightOperand ); VALUE rightVector = Vector2_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector2_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector2_GetY( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector2_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector2_GetY( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "/" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "/" ), 1, rightX );
@ -160,10 +182,10 @@ static VALUE Vector2_Divide( VALUE self, VALUE aRightOperand )
static VALUE Vector2_Equal( VALUE self, VALUE anArgument ) static VALUE Vector2_Equal( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector2_ForceType( anArgument ); VALUE aVector = Vector2_ForceType( anArgument );
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector2_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector2_GetY( self );
VALUE rightX = rb_funcall( aVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector2_GetX( rightVector );
VALUE rightY = rb_funcall( aVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector2_GetY( rightVector );
if( rb_funcall( leftX, rb_intern( "==" ), 1, rightX ) == Qtrue && if( rb_funcall( leftX, rb_intern( "==" ), 1, rightX ) == Qtrue &&
rb_funcall( leftY, rb_intern( "==" ), 1, rightY ) == Qtrue ) rb_funcall( leftY, rb_intern( "==" ), 1, rightY ) == Qtrue )
@ -180,10 +202,10 @@ static VALUE Vector2_Equal( VALUE self, VALUE anArgument )
static VALUE Vector2_StrictEqual( VALUE self, VALUE anArgument ) static VALUE Vector2_StrictEqual( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector2_ForceType( anArgument ); VALUE aVector = Vector2_ForceType( anArgument );
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector2_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector2_GetY( self );
VALUE rightX = rb_funcall( aVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector2_GetX( rightVector );
VALUE rightY = rb_funcall( aVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector2_GetY( rightVector );
if( rb_funcall( leftX, rb_intern( "eql?" ), 1, rightX ) == Qtrue && if( rb_funcall( leftX, rb_intern( "eql?" ), 1, rightX ) == Qtrue &&
rb_funcall( leftY, rb_intern( "eql?" ), 1, rightY ) == Qtrue ) rb_funcall( leftY, rb_intern( "eql?" ), 1, rightY ) == Qtrue )

View File

@ -25,6 +25,12 @@
#include "ruby.h" #include "ruby.h"
VALUE Vector2_GetX( VALUE self );
VALUE Vector2_GetY( VALUE self );
VALUE Vector2_SetX( VALUE self, VALUE aVal );
VALUE Vector2_SetY( VALUE self, VALUE aVal );
VALUE Vector2_ForceType( VALUE someValue ); VALUE Vector2_ForceType( VALUE someValue );
void Init_Vector2( void ); void Init_Vector2( void );

View File

@ -25,6 +25,38 @@
VALUE globalVector3Class; VALUE globalVector3Class;
VALUE Vector3_GetX( VALUE self )
{
static ID idX = rb_intern( "x" );
return rb_funcall( self, idX, 0 );
}
VALUE Vector3_GetY( VALUE self )
{
static ID idY = rb_intern( "y" );
return rb_funcall( self, idY, 0 );
}
VALUE Vector3_GetZ( VALUE self )
{
static ID idZ = rb_intern( "z" );
return rb_funcall( self, idZ, 0 );
}
VALUE Vector3_SetX( VALUE self, VALUE aVal )
{
static ID idX = rb_intern( "x=" );
return rb_funcall( self, idX, 1, aVal );
}
VALUE Vector3_SetY( VALUE self, VALUE aVal )
{
static ID idY = rb_intern( "y=" );
return rb_funcall( self, idY, 1, aVal );
}
VALUE Vector3_SetZ( VALUE self, VALUE aVal )
{
static ID idZ = rb_intern( "z=" );
return rb_funcall( self, idZ, 1, aVal );
}
/* Internal function /* Internal function
* Forces the argument someValue to be a Vector3. IF it can convert it then it will. * Forces the argument someValue to be a Vector3. IF it can convert it then it will.
* So you can always safely asume that this function returns a Vector3 object. * So you can always safely asume that this function returns a Vector3 object.
@ -55,13 +87,13 @@ VALUE Vector3_ForceType( VALUE someValue )
static void Vector3_internal_CopyFrom( VALUE self, VALUE aSource ) static void Vector3_internal_CopyFrom( VALUE self, VALUE aSource )
{ {
VALUE vectorSource = Vector3_ForceType( aSource ); VALUE vectorSource = Vector3_ForceType( aSource );
VALUE x = rb_funcall( vectorSource, rb_intern( "x" ), 0 ); VALUE x = Vector3_GetX( self );
VALUE y = rb_funcall( vectorSource, rb_intern( "y" ), 0 ); VALUE y = Vector3_GetY( self );
VALUE z = rb_funcall( vectorSource, rb_intern( "z" ), 0 ); VALUE z = Vector3_GetZ( self );
rb_funcall( self, rb_intern( "x=" ), 1, x ); Vector3_SetX( self, x );
rb_funcall( self, rb_intern( "y=" ), 1, y ); Vector3_SetY( self, y );
rb_funcall( self, rb_intern( "z=" ), 1, z ); Vector3_SetZ( self, z );
rb_iv_set( self, "@dataType", rb_iv_get( vectorSource, "@dataType" ) ); rb_iv_set( self, "@dataType", rb_iv_get( vectorSource, "@dataType" ) );
} }
@ -84,13 +116,13 @@ static void Vector3_internal_ValidateTypes( VALUE aFirst, VALUE aSecond, VALUE a
/* */ /* */
static VALUE Vector3_Negate( VALUE self ) static VALUE Vector3_Negate( VALUE self )
{ {
VALUE x = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE x = Vector3_GetX( self );
VALUE y = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE y = Vector3_GetY( self );
VALUE z = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE z = Vector3_GetZ( self );
VALUE negatedX = rb_funcall( x, rb_intern( "-@" ), 0 ); VALUE negatedX = rb_funcall( x, rb_intern( "-@" ), 0 );
VALUE negatedY = rb_funcall( y, rb_intern( "-@" ), 0 ); VALUE negatedY = rb_funcall( y, rb_intern( "-@" ), 0 );
VALUE negatedZ = rb_funcall( z, rb_intern( "-@" ), 0 ); VALUE negatedZ = rb_funcall( z, rb_intern( "-@" ), 0 );
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, negatedX, negatedY, negatedZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 3, negatedX, negatedY, negatedZ );
} }
/* */ /* */
@ -98,19 +130,19 @@ static VALUE Vector3_Add( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector3_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector3_GetY( self );
VALUE leftZ = rb_funcall( self, rb_intern( "z" ), 0 ); VALUE leftZ = Vector3_GetZ( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector3_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector3_GetY( rightVector );
VALUE rightZ = rb_funcall( rightVector, rb_intern( "z" ), 0 ); VALUE rightZ = Vector3_GetZ( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "+" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "+" ), 1, rightX );
VALUE newY = rb_funcall( leftY, rb_intern( "+" ), 1, rightY ); VALUE newY = rb_funcall( leftY, rb_intern( "+" ), 1, rightY );
VALUE newZ = rb_funcall( leftZ, rb_intern( "+" ), 1, rightZ ); VALUE newZ = rb_funcall( leftZ, rb_intern( "+" ), 1, rightZ );
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 3, newX, newY, newZ );
} }
/* */ /* */
@ -118,19 +150,19 @@ static VALUE Vector3_Subtract( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector3_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector3_GetY( self );
VALUE leftZ = rb_funcall( self, rb_intern( "z" ), 0 ); VALUE leftZ = Vector3_GetZ( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector3_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector3_GetY( rightVector );
VALUE rightZ = rb_funcall( rightVector, rb_intern( "z" ), 0 ); VALUE rightZ = Vector3_GetZ( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "-" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "-" ), 1, rightX );
VALUE newY = rb_funcall( leftY, rb_intern( "-" ), 1, rightY ); VALUE newY = rb_funcall( leftY, rb_intern( "-" ), 1, rightY );
VALUE newZ = rb_funcall( leftZ, rb_intern( "-" ), 1, rightZ ); VALUE newZ = rb_funcall( leftZ, rb_intern( "-" ), 1, rightZ );
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 3, newX, newY, newZ );
} }
/* */ /* */
@ -138,19 +170,19 @@ static VALUE Vector3_Multiply( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector3_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector3_GetY( self );
VALUE leftZ = rb_funcall( self, rb_intern( "z" ), 0 ); VALUE leftZ = Vector3_GetZ( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector3_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector3_GetY( rightVector );
VALUE rightZ = rb_funcall( rightVector, rb_intern( "z" ), 0 ); VALUE rightZ = Vector3_GetZ( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "*" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "*" ), 1, rightX );
VALUE newY = rb_funcall( leftY, rb_intern( "*" ), 1, rightY ); VALUE newY = rb_funcall( leftY, rb_intern( "*" ), 1, rightY );
VALUE newZ = rb_funcall( leftZ, rb_intern( "*" ), 1, rightZ ); VALUE newZ = rb_funcall( leftZ, rb_intern( "*" ), 1, rightZ );
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 3, newX, newY, newZ );
} }
/* */ /* */
@ -158,31 +190,31 @@ static VALUE Vector3_Divide( VALUE self, VALUE aRightOperand )
{ {
VALUE rightVector = Vector3_ForceType( aRightOperand ); VALUE rightVector = Vector3_ForceType( aRightOperand );
// Get values // Get values
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector3_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector3_GetY( self );
VALUE leftZ = rb_funcall( self, rb_intern( "z" ), 0 ); VALUE leftZ = Vector3_GetZ( self );
VALUE rightX = rb_funcall( rightVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector3_GetX( rightVector );
VALUE rightY = rb_funcall( rightVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector3_GetY( rightVector );
VALUE rightZ = rb_funcall( rightVector, rb_intern( "z" ), 0 ); VALUE rightZ = Vector3_GetZ( rightVector );
// Do calculation // Do calculation
VALUE newX = rb_funcall( leftX, rb_intern( "/" ), 1, rightX ); VALUE newX = rb_funcall( leftX, rb_intern( "/" ), 1, rightX );
VALUE newY = rb_funcall( leftY, rb_intern( "/" ), 1, rightY ); VALUE newY = rb_funcall( leftY, rb_intern( "/" ), 1, rightY );
VALUE newZ = rb_funcall( leftZ, rb_intern( "/" ), 1, rightZ ); VALUE newZ = rb_funcall( leftZ, rb_intern( "/" ), 1, rightZ );
return rb_funcall( globalVector3Class, rb_intern( "new" ), 2, newX, newY, newZ ); return rb_funcall( globalVector3Class, rb_intern( "new" ), 3, newX, newY, newZ );
} }
/* */ /* */
static VALUE Vector3_Equal( VALUE self, VALUE anArgument ) static VALUE Vector3_Equal( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector3_ForceType( anArgument ); VALUE aVector = Vector3_ForceType( anArgument );
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector3_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector3_GetY( self );
VALUE leftZ = rb_funcall( self, rb_intern( "z" ), 0 ); VALUE leftZ = Vector3_GetZ( self );
VALUE rightX = rb_funcall( aVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector3_GetX( rightVector );
VALUE rightY = rb_funcall( aVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector3_GetY( rightVector );
VALUE rightZ = rb_funcall( aVector, rb_intern( "z" ), 0 ); VALUE rightZ = Vector3_GetZ( rightVector );
if( rb_funcall( leftX, rb_intern( "==" ), 1, rightX ) == Qtrue && if( rb_funcall( leftX, rb_intern( "==" ), 1, rightX ) == Qtrue &&
rb_funcall( leftY, rb_intern( "==" ), 1, rightY ) == Qtrue && rb_funcall( leftY, rb_intern( "==" ), 1, rightY ) == Qtrue &&
@ -200,12 +232,12 @@ static VALUE Vector3_Equal( VALUE self, VALUE anArgument )
static VALUE Vector3_StrictEqual( VALUE self, VALUE anArgument ) static VALUE Vector3_StrictEqual( VALUE self, VALUE anArgument )
{ {
VALUE aVector = Vector3_ForceType( anArgument ); VALUE aVector = Vector3_ForceType( anArgument );
VALUE leftX = rb_funcall( self, rb_intern( "x" ), 0 ); VALUE leftX = Vector3_GetX( self );
VALUE leftY = rb_funcall( self, rb_intern( "y" ), 0 ); VALUE leftY = Vector3_GetY( self );
VALUE leftZ = rb_funcall( self, rb_intern( "z" ), 0 ); VALUE leftZ = Vector3_GetZ( self );
VALUE rightX = rb_funcall( aVector, rb_intern( "x" ), 0 ); VALUE rightX = Vector3_GetX( rightVector );
VALUE rightY = rb_funcall( aVector, rb_intern( "y" ), 0 ); VALUE rightY = Vector3_GetY( rightVector );
VALUE rightZ = rb_funcall( aVector, rb_intern( "z" ), 0 ); VALUE rightZ = Vector3_GetZ( rightVector );
if( rb_funcall( leftX, rb_intern( "eql?" ), 1, rightX ) == Qtrue && if( rb_funcall( leftX, rb_intern( "eql?" ), 1, rightX ) == Qtrue &&
rb_funcall( leftY, rb_intern( "eql?" ), 1, rightY ) == Qtrue && rb_funcall( leftY, rb_intern( "eql?" ), 1, rightY ) == Qtrue &&

View File

@ -25,6 +25,14 @@
#include "ruby.h" #include "ruby.h"
VALUE Vector3_GetX( VALUE self );
VALUE Vector3_GetY( VALUE self );
VALUE Vector3_GetZ( VALUE self );
VALUE Vector3_SetX( VALUE self, VALUE aVal );
VALUE Vector3_SetY( VALUE self, VALUE aVal );
VALUE Vector3_SetZ( VALUE self, VALUE aVal );
VALUE Vector3_ForceType( VALUE someValue ); VALUE Vector3_ForceType( VALUE someValue );
void Init_Vector3( void ); void Init_Vector3( void );