rmath3d 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/ext/rmath3d/RMath3D.h +3 -3
- data/ext/rmath3d/RMtx2.c +1 -1
- data/ext/rmath3d/RMtx2.h +1 -1
- data/ext/rmath3d/RMtx3.c +1 -1
- data/ext/rmath3d/RMtx3.h +1 -1
- data/ext/rmath3d/RMtx4.c +1 -1
- data/ext/rmath3d/RMtx4.h +1 -1
- data/ext/rmath3d/RQuat.c +1 -1
- data/ext/rmath3d/RQuat.h +1 -1
- data/ext/rmath3d/RType.h +1 -1
- data/ext/rmath3d/RVec2.c +1 -1
- data/ext/rmath3d/RVec2.h +1 -1
- data/ext/rmath3d/RVec3.c +1 -1
- data/ext/rmath3d/RVec3.h +1 -1
- data/ext/rmath3d/RVec4.c +1 -1
- data/ext/rmath3d/RVec4.h +1 -1
- data/ext/rmath3d/rmath3d.c +169 -445
- data/lib/rmath3d/rmath3d_plain.rb +36 -36
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc8123d1ad73cb760f30d7c6a3496f13ad54fcb1
|
4
|
+
data.tar.gz: 41ae8b2437dfe3fdc2b0ec6c01fc511a0e5ada20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39615da4c1208ebfdb06644ce2a6612ed88172afc334c36eb9a08b20211c3fb89359bcdb4e348924fd09fad057745397774be8f3de00e211373a98c6cc6ab11c
|
7
|
+
data.tar.gz: 7e6b01b7f44b95ccb8f2c8a9419d74f730ef1bd6eac59afa7dc128c1e5cfa6ffb171cd151957a8d6d41a4fcbc987ebae63487bb0b30c5299513c936c7179f205
|
data/ChangeLog
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
2017-07-22 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
|
+
|
3
|
+
* Added 'Integer' type for argument type branching (constant ::Fixnum is deprecated since ruby 2.4).
|
4
|
+
|
1
5
|
2015-08-23 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
6
|
|
3
7
|
* rmath3d.c (def ==): Removed control path returning Qnil.
|
data/LICENSE.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
rmath3d : Ruby math module for 3D Applications
|
2
|
-
Copyright (c) 2008-
|
2
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
3
3
|
|
4
4
|
This software is provided 'as-is', without any express or implied
|
5
5
|
warranty. In no event will the authors be held liable for any damages
|
data/README.md
CHANGED
data/ext/rmath3d/RMath3D.h
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef RMATH3D_H_INCLUDED
|
2
|
+
#define RMATH3D_H_INCLUDED
|
3
3
|
|
4
4
|
#include "RType.h"
|
5
5
|
#include "RVec2.h"
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
/*
|
16
16
|
RMath : Ruby math module for 3D Applications
|
17
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
17
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
18
18
|
|
19
19
|
This software is provided 'as-is', without any express or implied
|
20
20
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx2.c
CHANGED
@@ -232,7 +232,7 @@ RMtx2Scale( RMtx2* out, const RMtx2* m, rmReal f )
|
|
232
232
|
|
233
233
|
/*
|
234
234
|
RMath : Ruby math module for 3D Applications
|
235
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
235
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
236
236
|
|
237
237
|
This software is provided 'as-is', without any express or implied
|
238
238
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx2.h
CHANGED
@@ -65,7 +65,7 @@ void RMtx2Scale( RMtx2* out, const RMtx2* m, rmReal f );
|
|
65
65
|
|
66
66
|
/*
|
67
67
|
RMath : Ruby math module for 3D Applications
|
68
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
68
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
69
69
|
|
70
70
|
This software is provided 'as-is', without any express or implied
|
71
71
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx3.c
CHANGED
@@ -347,7 +347,7 @@ RMtx3Scale( RMtx3* out, const RMtx3* m, rmReal f )
|
|
347
347
|
|
348
348
|
/*
|
349
349
|
RMath : Ruby math module for 3D Applications
|
350
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
350
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
351
351
|
|
352
352
|
This software is provided 'as-is', without any express or implied
|
353
353
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx3.h
CHANGED
@@ -72,7 +72,7 @@ void RMtx3Scale( RMtx3* out, const RMtx3* m, rmReal f );
|
|
72
72
|
|
73
73
|
/*
|
74
74
|
RMath : Ruby math module for 3D Applications
|
75
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
75
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
76
76
|
|
77
77
|
This software is provided 'as-is', without any express or implied
|
78
78
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx4.c
CHANGED
@@ -549,7 +549,7 @@ RMtx4OrthoOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bottom, rmR
|
|
549
549
|
|
550
550
|
/*
|
551
551
|
RMath : Ruby math module for 3D Applications
|
552
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
552
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
553
553
|
|
554
554
|
This software is provided 'as-is', without any express or implied
|
555
555
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RMtx4.h
CHANGED
@@ -87,7 +87,7 @@ void RMtx4OrthoOffCenterRH( RMtx4* out, rmReal left, rmReal right, rmReal bot
|
|
87
87
|
|
88
88
|
/*
|
89
89
|
RMath : Ruby math module for 3D Applications
|
90
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
90
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
91
91
|
|
92
92
|
This software is provided 'as-is', without any express or implied
|
93
93
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RQuat.c
CHANGED
@@ -344,7 +344,7 @@ RQuatToAxisAngle( const RQuat* in, struct RVec3* axis, rmReal* radian )
|
|
344
344
|
|
345
345
|
/*
|
346
346
|
RMath : Ruby math module for 3D Applications
|
347
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
347
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
348
348
|
|
349
349
|
This software is provided 'as-is', without any express or implied
|
350
350
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RQuat.h
CHANGED
@@ -69,7 +69,7 @@ void RQuatToAxisAngle( const RQuat* in, struct RVec3* axis, rmReal* radian );
|
|
69
69
|
|
70
70
|
/*
|
71
71
|
RMath : Ruby math module for 3D Applications
|
72
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
72
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
73
73
|
|
74
74
|
This software is provided 'as-is', without any express or implied
|
75
75
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RType.h
CHANGED
@@ -53,7 +53,7 @@ typedef double rmReal;
|
|
53
53
|
|
54
54
|
/*
|
55
55
|
RMath : Ruby math module for 3D Applications
|
56
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
56
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
57
57
|
|
58
58
|
This software is provided 'as-is', without any express or implied
|
59
59
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec2.c
CHANGED
@@ -144,7 +144,7 @@ RVec2Transform( RVec2* out, const RMtx2* m, const RVec2* in )
|
|
144
144
|
|
145
145
|
/*
|
146
146
|
RMath : Ruby math module for 3D Applications
|
147
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>.
|
147
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>.
|
148
148
|
|
149
149
|
This software is provided 'as-is', without any express or implied
|
150
150
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec2.h
CHANGED
@@ -57,7 +57,7 @@ void RVec2Transform( struct RVec2* out, const struct RMtx2* m, const RVec2* i
|
|
57
57
|
|
58
58
|
/*
|
59
59
|
RMath : Ruby math module for 3D Applications
|
60
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
60
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
61
61
|
|
62
62
|
This software is provided 'as-is', without any express or implied
|
63
63
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec3.c
CHANGED
@@ -262,7 +262,7 @@ RVec3TransformByQuaternion( RVec3* out, const struct RQuat* q, const RVec3* in )
|
|
262
262
|
|
263
263
|
/*
|
264
264
|
RMath : Ruby math module for 3D Applications
|
265
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>.
|
265
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>.
|
266
266
|
|
267
267
|
This software is provided 'as-is', without any express or implied
|
268
268
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec3.h
CHANGED
@@ -66,7 +66,7 @@ void RVec3TransformByQuaternion( RVec3* out, const struct RQuat* q, const RVe
|
|
66
66
|
|
67
67
|
/*
|
68
68
|
RMath : Ruby math module for 3D Applications
|
69
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
69
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
70
70
|
|
71
71
|
This software is provided 'as-is', without any express or implied
|
72
72
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec4.c
CHANGED
@@ -192,7 +192,7 @@ RVec4TransformTransposed( RVec4* out, const struct RMtx4* m, const RVec4* in )
|
|
192
192
|
|
193
193
|
/*
|
194
194
|
RMath : Ruby math module for 3D Applications
|
195
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
195
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
196
196
|
|
197
197
|
This software is provided 'as-is', without any express or implied
|
198
198
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/RVec4.h
CHANGED
@@ -63,7 +63,7 @@ void RVec4TransformTransposed( RVec4* out, const struct RMtx4* m, const RVec4
|
|
63
63
|
|
64
64
|
/*
|
65
65
|
RMath : Ruby math module for 3D Applications
|
66
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
66
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
67
67
|
|
68
68
|
This software is provided 'as-is', without any express or implied
|
69
69
|
warranty. In no event will the authors be held liable for any damages
|
data/ext/rmath3d/rmath3d.c
CHANGED
@@ -200,45 +200,32 @@ RMtx2_initialize( int argc, VALUE* argv, VALUE self )
|
|
200
200
|
case 1:
|
201
201
|
{
|
202
202
|
VALUE arg = argv[0];
|
203
|
-
|
204
|
-
{
|
205
|
-
case T_FIXNUM:
|
206
|
-
case T_FLOAT:
|
207
|
-
{
|
203
|
+
if ( RB_FLOAT_TYPE_P(arg) || RB_INTEGER_TYPE_P(arg) ) {
|
208
204
|
/* convert to float */
|
209
205
|
rmReal f = NUM2DBL( arg );
|
210
206
|
RMtx2SetElements( v,
|
211
207
|
f,f,
|
212
208
|
f,f );
|
213
209
|
return self;
|
214
|
-
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
210
|
+
} else {
|
211
|
+
if ( TYPE( arg ) == T_DATA ) {
|
212
|
+
if ( IsRMtx2(arg) ) {
|
213
|
+
/* Copy Constructor */
|
214
|
+
RMtx2* other;
|
215
|
+
TypedData_Get_Struct( arg, RMtx2, &RMtx2_type, other );
|
216
|
+
RMtx2Copy( v, other );
|
217
|
+
return self;
|
218
|
+
} else {
|
219
|
+
return Qnil;
|
220
|
+
}
|
221
|
+
} else {
|
222
|
+
rb_raise( rb_eTypeError,
|
223
|
+
"RMtx2_new : Unknown type %s.",
|
224
|
+
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
225
|
+
);
|
228
226
|
return Qnil;
|
227
|
+
}
|
229
228
|
}
|
230
|
-
break;
|
231
|
-
|
232
|
-
default:
|
233
|
-
{
|
234
|
-
rb_raise( rb_eTypeError,
|
235
|
-
"RMtx2_new : Unknown type %s.",
|
236
|
-
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
237
|
-
);
|
238
|
-
return Qnil;
|
239
|
-
}
|
240
|
-
break;
|
241
|
-
} /* End : switch ( TYPE( arg ) ) */
|
242
229
|
} /* End : case 1 */
|
243
230
|
break;
|
244
231
|
|
@@ -251,18 +238,10 @@ RMtx2_initialize( int argc, VALUE* argv, VALUE self )
|
|
251
238
|
for ( col = 0; col < 2; ++col )
|
252
239
|
{
|
253
240
|
int i = 2*row + col;
|
254
|
-
|
255
|
-
{
|
256
|
-
case T_FIXNUM:
|
257
|
-
case T_FLOAT:
|
258
|
-
{
|
241
|
+
if ( RB_FLOAT_TYPE_P(argv[i]) || RB_INTEGER_TYPE_P(argv[i]) ) {
|
259
242
|
rmReal f = NUM2DBL( argv[i] );
|
260
243
|
RMtx2SetElement( v, row, col, f );
|
261
|
-
}
|
262
|
-
break;
|
263
|
-
|
264
|
-
default:
|
265
|
-
{
|
244
|
+
} else {
|
266
245
|
rb_raise( rb_eTypeError,
|
267
246
|
"RMtx2_new : Unknown type %s. at arg %d",
|
268
247
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self ),
|
@@ -270,8 +249,6 @@ RMtx2_initialize( int argc, VALUE* argv, VALUE self )
|
|
270
249
|
);
|
271
250
|
return Qnil;
|
272
251
|
}
|
273
|
-
break;
|
274
|
-
}
|
275
252
|
} /* End : for ( col = 0; col < 2; ++col ) */
|
276
253
|
} /* End : for ( row = 0; row < 2; ++row ) */
|
277
254
|
|
@@ -371,21 +348,12 @@ RMtx2_coerce( VALUE self, VALUE other )
|
|
371
348
|
RMtx2* v = NULL;
|
372
349
|
TypedData_Get_Struct( self, RMtx2, &RMtx2_type, v );
|
373
350
|
|
374
|
-
|
375
|
-
{
|
376
|
-
case T_FLOAT:
|
377
|
-
case T_FIXNUM:
|
378
|
-
case T_BIGNUM:
|
379
|
-
{
|
351
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
380
352
|
/* 'other (op) RMtx2'
|
381
353
|
* -> try again as 'RMtx2 (op) other'
|
382
354
|
*/
|
383
355
|
return rb_ary_new3( 2, self, other );
|
384
|
-
}
|
385
|
-
break;
|
386
|
-
|
387
|
-
default:
|
388
|
-
{
|
356
|
+
} else {
|
389
357
|
rb_raise( rb_eTypeError,
|
390
358
|
"%s can't be coerced into %s",
|
391
359
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other ),
|
@@ -393,8 +361,6 @@ RMtx2_coerce( VALUE self, VALUE other )
|
|
393
361
|
);
|
394
362
|
return Qnil;
|
395
363
|
}
|
396
|
-
break;
|
397
|
-
}
|
398
364
|
}
|
399
365
|
|
400
366
|
/*
|
@@ -1114,11 +1080,7 @@ RMtx3_initialize( int argc, VALUE* argv, VALUE self )
|
|
1114
1080
|
case 1:
|
1115
1081
|
{
|
1116
1082
|
VALUE arg = argv[0];
|
1117
|
-
|
1118
|
-
{
|
1119
|
-
case T_FIXNUM:
|
1120
|
-
case T_FLOAT:
|
1121
|
-
{
|
1083
|
+
if ( RB_FLOAT_TYPE_P(arg) || RB_INTEGER_TYPE_P(arg) ) {
|
1122
1084
|
/* convert to float */
|
1123
1085
|
rmReal f = NUM2DBL( arg );
|
1124
1086
|
RMtx3SetElements( v,
|
@@ -1126,34 +1088,25 @@ RMtx3_initialize( int argc, VALUE* argv, VALUE self )
|
|
1126
1088
|
f,f,f,
|
1127
1089
|
f,f,f );
|
1128
1090
|
return self;
|
1129
|
-
}
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1091
|
+
} else {
|
1092
|
+
if ( TYPE( arg ) == T_DATA ) {
|
1093
|
+
if ( IsRMtx3(arg) ) {
|
1094
|
+
/* Copy Constructor */
|
1095
|
+
RMtx3* other;
|
1096
|
+
TypedData_Get_Struct( arg , RMtx3, &RMtx3_type, other );
|
1097
|
+
RMtx3Copy( v, other );
|
1098
|
+
return self;
|
1099
|
+
} else {
|
1100
|
+
return Qnil;
|
1101
|
+
}
|
1102
|
+
} else {
|
1103
|
+
rb_raise( rb_eTypeError,
|
1104
|
+
"RMtx3_new : Unknown type %s.",
|
1105
|
+
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
1106
|
+
);
|
1143
1107
|
return Qnil;
|
1108
|
+
}
|
1144
1109
|
}
|
1145
|
-
break;
|
1146
|
-
|
1147
|
-
default:
|
1148
|
-
{
|
1149
|
-
rb_raise( rb_eTypeError,
|
1150
|
-
"RMtx3_new : Unknown type %s.",
|
1151
|
-
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
1152
|
-
);
|
1153
|
-
return Qnil;
|
1154
|
-
}
|
1155
|
-
break;
|
1156
|
-
} /* End : switch ( TYPE( arg ) ) */
|
1157
1110
|
} /* End : case 1 */
|
1158
1111
|
break;
|
1159
1112
|
|
@@ -1166,18 +1119,10 @@ RMtx3_initialize( int argc, VALUE* argv, VALUE self )
|
|
1166
1119
|
for ( col = 0; col < 3; ++col )
|
1167
1120
|
{
|
1168
1121
|
int i = 3*row + col;
|
1169
|
-
|
1170
|
-
{
|
1171
|
-
case T_FIXNUM:
|
1172
|
-
case T_FLOAT:
|
1173
|
-
{
|
1122
|
+
if ( RB_FLOAT_TYPE_P(argv[i]) || RB_INTEGER_TYPE_P(argv[i]) ) {
|
1174
1123
|
rmReal f = NUM2DBL( argv[i] );
|
1175
1124
|
RMtx3SetElement( v, row, col, f );
|
1176
|
-
}
|
1177
|
-
break;
|
1178
|
-
|
1179
|
-
default:
|
1180
|
-
{
|
1125
|
+
} else {
|
1181
1126
|
rb_raise( rb_eTypeError,
|
1182
1127
|
"RMtx3_new : Unknown type %s. at arg %d",
|
1183
1128
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self ),
|
@@ -1185,8 +1130,6 @@ RMtx3_initialize( int argc, VALUE* argv, VALUE self )
|
|
1185
1130
|
);
|
1186
1131
|
return Qnil;
|
1187
1132
|
}
|
1188
|
-
break;
|
1189
|
-
}
|
1190
1133
|
} /* End : for ( col = 0; col < 3; ++col ) */
|
1191
1134
|
} /* End : for ( row = 0; row < 3; ++row ) */
|
1192
1135
|
|
@@ -1286,21 +1229,12 @@ RMtx3_coerce( VALUE self, VALUE other )
|
|
1286
1229
|
RMtx3* v = NULL;
|
1287
1230
|
TypedData_Get_Struct( self, RMtx3, &RMtx3_type, v );
|
1288
1231
|
|
1289
|
-
|
1290
|
-
{
|
1291
|
-
case T_FLOAT:
|
1292
|
-
case T_FIXNUM:
|
1293
|
-
case T_BIGNUM:
|
1294
|
-
{
|
1232
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
1295
1233
|
/* 'other (op) RMtx3'
|
1296
1234
|
* -> try again as 'RMtx3 (op) other'
|
1297
1235
|
*/
|
1298
1236
|
return rb_ary_new3( 2, self, other );
|
1299
|
-
}
|
1300
|
-
break;
|
1301
|
-
|
1302
|
-
default:
|
1303
|
-
{
|
1237
|
+
} else {
|
1304
1238
|
rb_raise( rb_eTypeError,
|
1305
1239
|
"%s can't be coerced into %s",
|
1306
1240
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other ),
|
@@ -1308,8 +1242,6 @@ RMtx3_coerce( VALUE self, VALUE other )
|
|
1308
1242
|
);
|
1309
1243
|
return Qnil;
|
1310
1244
|
}
|
1311
|
-
break;
|
1312
|
-
}
|
1313
1245
|
}
|
1314
1246
|
|
1315
1247
|
/*
|
@@ -2235,11 +2167,7 @@ RMtx4_initialize( int argc, VALUE* argv, VALUE self )
|
|
2235
2167
|
case 1:
|
2236
2168
|
{
|
2237
2169
|
VALUE arg = argv[0];
|
2238
|
-
|
2239
|
-
{
|
2240
|
-
case T_FIXNUM:
|
2241
|
-
case T_FLOAT:
|
2242
|
-
{
|
2170
|
+
if ( RB_FLOAT_TYPE_P(arg) || RB_INTEGER_TYPE_P(arg) ) {
|
2243
2171
|
/* convert to float */
|
2244
2172
|
rmReal f = NUM2DBL( arg );
|
2245
2173
|
RMtx4SetElements( v,
|
@@ -2248,34 +2176,25 @@ RMtx4_initialize( int argc, VALUE* argv, VALUE self )
|
|
2248
2176
|
f,f,f,f,
|
2249
2177
|
f,f,f,f );
|
2250
2178
|
return self;
|
2251
|
-
}
|
2252
|
-
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
2263
|
-
|
2264
|
-
|
2179
|
+
} else {
|
2180
|
+
if ( TYPE( arg ) == T_DATA ) {
|
2181
|
+
if ( IsRMtx4(arg) ) {
|
2182
|
+
/* Copy Constructor */
|
2183
|
+
RMtx4* other;
|
2184
|
+
TypedData_Get_Struct( arg , RMtx4, &RMtx4_type, other );
|
2185
|
+
RMtx4Copy( v, other );
|
2186
|
+
return self;
|
2187
|
+
} else {
|
2188
|
+
return Qnil;
|
2189
|
+
}
|
2190
|
+
} else {
|
2191
|
+
rb_raise( rb_eTypeError,
|
2192
|
+
"RMtx4_new : Unknown type %s.",
|
2193
|
+
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
2194
|
+
);
|
2265
2195
|
return Qnil;
|
2196
|
+
}
|
2266
2197
|
}
|
2267
|
-
break;
|
2268
|
-
|
2269
|
-
default:
|
2270
|
-
{
|
2271
|
-
rb_raise( rb_eTypeError,
|
2272
|
-
"RMtx4_new : Unknown type %s.",
|
2273
|
-
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
2274
|
-
);
|
2275
|
-
return Qnil;
|
2276
|
-
}
|
2277
|
-
break;
|
2278
|
-
} /* End : switch ( TYPE( arg ) ) */
|
2279
2198
|
} /* End : case 1 */
|
2280
2199
|
break;
|
2281
2200
|
|
@@ -2288,18 +2207,10 @@ RMtx4_initialize( int argc, VALUE* argv, VALUE self )
|
|
2288
2207
|
for ( col = 0; col < 4; ++col )
|
2289
2208
|
{
|
2290
2209
|
int i = 4*row + col;
|
2291
|
-
|
2292
|
-
{
|
2293
|
-
case T_FIXNUM:
|
2294
|
-
case T_FLOAT:
|
2295
|
-
{
|
2210
|
+
if ( RB_FLOAT_TYPE_P(argv[i]) || RB_INTEGER_TYPE_P(argv[i]) ) {
|
2296
2211
|
rmReal f = NUM2DBL( argv[i] );
|
2297
2212
|
RMtx4SetElement( v, row, col, f );
|
2298
|
-
}
|
2299
|
-
break;
|
2300
|
-
|
2301
|
-
default:
|
2302
|
-
{
|
2213
|
+
} else {
|
2303
2214
|
rb_raise( rb_eTypeError,
|
2304
2215
|
"RMtx4_new : Unknown type %s. at arg %d",
|
2305
2216
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self ),
|
@@ -2307,8 +2218,6 @@ RMtx4_initialize( int argc, VALUE* argv, VALUE self )
|
|
2307
2218
|
);
|
2308
2219
|
return Qnil;
|
2309
2220
|
}
|
2310
|
-
break;
|
2311
|
-
}
|
2312
2221
|
} /* End : for ( col = 0; col < 4; ++col ) */
|
2313
2222
|
} /* End : for ( row = 0; row < 4; ++row ) */
|
2314
2223
|
|
@@ -2410,21 +2319,12 @@ RMtx4_coerce( VALUE self, VALUE other )
|
|
2410
2319
|
RMtx4* v = NULL;
|
2411
2320
|
TypedData_Get_Struct( self, RMtx4, &RMtx4_type, v );
|
2412
2321
|
|
2413
|
-
|
2414
|
-
{
|
2415
|
-
case T_FLOAT:
|
2416
|
-
case T_FIXNUM:
|
2417
|
-
case T_BIGNUM:
|
2418
|
-
{
|
2322
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
2419
2323
|
/* 'other (op) RMtx4'
|
2420
2324
|
* -> try again as 'RMtx4 (op) other'
|
2421
2325
|
*/
|
2422
2326
|
return rb_ary_new3( 2, self, other );
|
2423
|
-
}
|
2424
|
-
break;
|
2425
|
-
|
2426
|
-
default:
|
2427
|
-
{
|
2327
|
+
} else {
|
2428
2328
|
rb_raise( rb_eTypeError,
|
2429
2329
|
"%s can't be coerced into %s",
|
2430
2330
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other ),
|
@@ -2432,8 +2332,6 @@ RMtx4_coerce( VALUE self, VALUE other )
|
|
2432
2332
|
);
|
2433
2333
|
return Qnil;
|
2434
2334
|
}
|
2435
|
-
break;
|
2436
|
-
}
|
2437
2335
|
}
|
2438
2336
|
|
2439
2337
|
/*
|
@@ -3784,43 +3682,30 @@ RQuat_initialize( int argc, VALUE* argv, VALUE self )
|
|
3784
3682
|
case 1:
|
3785
3683
|
{
|
3786
3684
|
VALUE arg = argv[0];
|
3787
|
-
|
3788
|
-
{
|
3789
|
-
case T_FIXNUM:
|
3790
|
-
case T_FLOAT:
|
3791
|
-
{
|
3685
|
+
if ( RB_FLOAT_TYPE_P(arg) || RB_INTEGER_TYPE_P(arg) ) {
|
3792
3686
|
/* convert to float */
|
3793
3687
|
rmReal f = NUM2DBL( arg );
|
3794
3688
|
RQuatSetElements( v, f,f,f,f );
|
3795
3689
|
return self;
|
3796
|
-
}
|
3797
|
-
|
3798
|
-
|
3799
|
-
|
3800
|
-
|
3801
|
-
|
3802
|
-
|
3803
|
-
|
3804
|
-
|
3805
|
-
|
3806
|
-
|
3807
|
-
|
3808
|
-
|
3809
|
-
|
3690
|
+
} else {
|
3691
|
+
if ( TYPE( arg ) == T_DATA ) {
|
3692
|
+
if ( IsRQuat(arg) ) {
|
3693
|
+
/* Copy Constructor */
|
3694
|
+
RQuat* other;
|
3695
|
+
TypedData_Get_Struct( arg , RQuat, &RQuat_type, other );
|
3696
|
+
RQuatSetElements( v, other->x, other->y, other->z, other->w );
|
3697
|
+
return self;
|
3698
|
+
} else {
|
3699
|
+
return Qnil;
|
3700
|
+
}
|
3701
|
+
} else {
|
3702
|
+
rb_raise( rb_eTypeError,
|
3703
|
+
"RQuat_new : Unknown type %s.",
|
3704
|
+
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
3705
|
+
);
|
3810
3706
|
return Qnil;
|
3707
|
+
}
|
3811
3708
|
}
|
3812
|
-
break;
|
3813
|
-
|
3814
|
-
default:
|
3815
|
-
{
|
3816
|
-
rb_raise( rb_eTypeError,
|
3817
|
-
"RQuat_new : Unknown type %s.",
|
3818
|
-
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
3819
|
-
);
|
3820
|
-
return Qnil;
|
3821
|
-
}
|
3822
|
-
break;
|
3823
|
-
} /* End : switch ( TYPE( arg ) ) */
|
3824
3709
|
} /* End : case 1 */
|
3825
3710
|
break;
|
3826
3711
|
|
@@ -3830,18 +3715,10 @@ RQuat_initialize( int argc, VALUE* argv, VALUE self )
|
|
3830
3715
|
int i;
|
3831
3716
|
for ( i = 0; i < argc; ++i )
|
3832
3717
|
{
|
3833
|
-
|
3834
|
-
{
|
3835
|
-
case T_FIXNUM:
|
3836
|
-
case T_FLOAT:
|
3837
|
-
{
|
3718
|
+
if ( RB_FLOAT_TYPE_P(argv[i]) || RB_INTEGER_TYPE_P(argv[i]) ) {
|
3838
3719
|
rmReal f = NUM2DBL( argv[i] );
|
3839
3720
|
v->e[i] = f;
|
3840
|
-
}
|
3841
|
-
break;
|
3842
|
-
|
3843
|
-
default:
|
3844
|
-
{
|
3721
|
+
} else {
|
3845
3722
|
rb_raise( rb_eTypeError,
|
3846
3723
|
"RQuat_new : Unknown type %s. at arg %d",
|
3847
3724
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self ),
|
@@ -3849,8 +3726,6 @@ RQuat_initialize( int argc, VALUE* argv, VALUE self )
|
|
3849
3726
|
);
|
3850
3727
|
return Qnil;
|
3851
3728
|
}
|
3852
|
-
break;
|
3853
|
-
}
|
3854
3729
|
} /* End : for ( i = 0; i < argc; ++i ) */
|
3855
3730
|
|
3856
3731
|
return self;
|
@@ -3936,21 +3811,12 @@ RQuat_coerce( VALUE self, VALUE other )
|
|
3936
3811
|
RQuat* v = NULL;
|
3937
3812
|
TypedData_Get_Struct( self, RQuat, &RQuat_type, v );
|
3938
3813
|
|
3939
|
-
|
3940
|
-
{
|
3941
|
-
case T_FLOAT:
|
3942
|
-
case T_FIXNUM:
|
3943
|
-
case T_BIGNUM:
|
3944
|
-
{
|
3814
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
3945
3815
|
/* 'other (op) RQuat'
|
3946
3816
|
* -> try again as 'RQuat (op) other'
|
3947
3817
|
*/
|
3948
3818
|
return rb_ary_new3( 2, self, other );
|
3949
|
-
}
|
3950
|
-
break;
|
3951
|
-
|
3952
|
-
default:
|
3953
|
-
{
|
3819
|
+
} else {
|
3954
3820
|
rb_raise( rb_eTypeError,
|
3955
3821
|
"%s can't be coerced into %s",
|
3956
3822
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other ),
|
@@ -3958,8 +3824,6 @@ RQuat_coerce( VALUE self, VALUE other )
|
|
3958
3824
|
);
|
3959
3825
|
return Qnil;
|
3960
3826
|
}
|
3961
|
-
break;
|
3962
|
-
}
|
3963
3827
|
}
|
3964
3828
|
|
3965
3829
|
/*
|
@@ -4506,27 +4370,18 @@ RQuat_op_binary_mult( VALUE self, VALUE other )
|
|
4506
4370
|
}
|
4507
4371
|
else
|
4508
4372
|
{
|
4509
|
-
|
4510
|
-
{
|
4511
|
-
case T_FIXNUM:
|
4512
|
-
case T_FLOAT:
|
4513
|
-
{
|
4373
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
4514
4374
|
f = NUM2DBL( other );
|
4515
4375
|
RQuatScale( &result, v, f );
|
4516
4376
|
|
4517
4377
|
return RQuat_from_source( &result );
|
4518
|
-
}
|
4519
|
-
break;
|
4520
|
-
|
4521
|
-
default:
|
4522
|
-
{
|
4378
|
+
} else {
|
4523
4379
|
rb_raise( rb_eTypeError,
|
4524
4380
|
"RQuat#* : Unknown type %s.",
|
4525
4381
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other )
|
4526
4382
|
);
|
4527
4383
|
return Qnil;
|
4528
4384
|
}
|
4529
|
-
} /* End : switch( TYPE(other) ) */
|
4530
4385
|
}
|
4531
4386
|
}
|
4532
4387
|
|
@@ -4640,7 +4495,7 @@ RQuat_op_assign_mult( VALUE self, VALUE other )
|
|
4640
4495
|
else
|
4641
4496
|
{
|
4642
4497
|
#ifdef RMATH_ENABLE_ARGUMENT_CHECK
|
4643
|
-
if (
|
4498
|
+
if ( !RB_FLOAT_TYPE_P(other) && !RB_INTEGER_TYPE_P(other) )
|
4644
4499
|
{
|
4645
4500
|
rb_raise( rb_eTypeError,
|
4646
4501
|
"RQuat#mul! : Unknown type %s.",
|
@@ -4785,43 +4640,30 @@ RVec2_initialize( int argc, VALUE* argv, VALUE self )
|
|
4785
4640
|
case 1:
|
4786
4641
|
{
|
4787
4642
|
VALUE arg = argv[0];
|
4788
|
-
|
4789
|
-
{
|
4790
|
-
case T_FIXNUM:
|
4791
|
-
case T_FLOAT:
|
4792
|
-
{
|
4643
|
+
if ( RB_FLOAT_TYPE_P(arg) || RB_INTEGER_TYPE_P(arg) ) {
|
4793
4644
|
/* convert to float */
|
4794
4645
|
rmReal f = NUM2DBL( arg );
|
4795
4646
|
RVec2SetElements( v, f,f );
|
4796
4647
|
return self;
|
4797
|
-
}
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4648
|
+
} else {
|
4649
|
+
if ( TYPE( arg ) == T_DATA ) {
|
4650
|
+
if ( IsRVec2(arg) ) {
|
4651
|
+
/* Copy Constructor */
|
4652
|
+
RVec2* other;
|
4653
|
+
TypedData_Get_Struct( arg , RVec2, &RVec2_type, other );
|
4654
|
+
RVec2SetElements( v, other->x, other->y );
|
4655
|
+
return self;
|
4656
|
+
} else {
|
4657
|
+
return Qnil;
|
4658
|
+
}
|
4659
|
+
} else {
|
4660
|
+
rb_raise( rb_eTypeError,
|
4661
|
+
"RVec2_new : Unknown type %s.",
|
4662
|
+
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
4663
|
+
);
|
4811
4664
|
return Qnil;
|
4665
|
+
}
|
4812
4666
|
}
|
4813
|
-
break;
|
4814
|
-
|
4815
|
-
default:
|
4816
|
-
{
|
4817
|
-
rb_raise( rb_eTypeError,
|
4818
|
-
"RVec2_new : Unknown type %s.",
|
4819
|
-
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
4820
|
-
);
|
4821
|
-
return Qnil;
|
4822
|
-
}
|
4823
|
-
break;
|
4824
|
-
} /* End : switch ( TYPE( arg ) ) */
|
4825
4667
|
} /* End : case 1 */
|
4826
4668
|
break;
|
4827
4669
|
|
@@ -4831,18 +4673,10 @@ RVec2_initialize( int argc, VALUE* argv, VALUE self )
|
|
4831
4673
|
int i;
|
4832
4674
|
for ( i = 0; i < argc; ++i )
|
4833
4675
|
{
|
4834
|
-
|
4835
|
-
{
|
4836
|
-
case T_FIXNUM:
|
4837
|
-
case T_FLOAT:
|
4838
|
-
{
|
4676
|
+
if ( RB_FLOAT_TYPE_P(argv[i]) || RB_INTEGER_TYPE_P(argv[i]) ) {
|
4839
4677
|
rmReal f = NUM2DBL( argv[i] );
|
4840
4678
|
v->e[i] = f;
|
4841
|
-
}
|
4842
|
-
break;
|
4843
|
-
|
4844
|
-
default:
|
4845
|
-
{
|
4679
|
+
} else {
|
4846
4680
|
rb_raise( rb_eTypeError,
|
4847
4681
|
"RVec2_new : Unknown type %s. at arg %d",
|
4848
4682
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self ),
|
@@ -4850,8 +4684,6 @@ RVec2_initialize( int argc, VALUE* argv, VALUE self )
|
|
4850
4684
|
);
|
4851
4685
|
return Qnil;
|
4852
4686
|
}
|
4853
|
-
break;
|
4854
|
-
}
|
4855
4687
|
} /* End : for ( i = 0; i < argc; ++i ) */
|
4856
4688
|
|
4857
4689
|
return self;
|
@@ -4935,21 +4767,12 @@ RVec2_coerce( VALUE self, VALUE other )
|
|
4935
4767
|
RVec2* v = NULL;
|
4936
4768
|
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
4937
4769
|
|
4938
|
-
|
4939
|
-
{
|
4940
|
-
case T_FLOAT:
|
4941
|
-
case T_FIXNUM:
|
4942
|
-
case T_BIGNUM:
|
4943
|
-
{
|
4770
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
4944
4771
|
/* 'other (op) RVec2'
|
4945
4772
|
* -> try again as 'RVec2 (op) other'
|
4946
4773
|
*/
|
4947
4774
|
return rb_ary_new3( 2, self, other );
|
4948
|
-
}
|
4949
|
-
break;
|
4950
|
-
|
4951
|
-
default:
|
4952
|
-
{
|
4775
|
+
} else {
|
4953
4776
|
rb_raise( rb_eTypeError,
|
4954
4777
|
"%s can't be coerced into %s",
|
4955
4778
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other ),
|
@@ -4957,8 +4780,6 @@ RVec2_coerce( VALUE self, VALUE other )
|
|
4957
4780
|
);
|
4958
4781
|
return Qnil;
|
4959
4782
|
}
|
4960
|
-
break;
|
4961
|
-
}
|
4962
4783
|
}
|
4963
4784
|
|
4964
4785
|
/*
|
@@ -5318,28 +5139,19 @@ RVec2_op_binary_mult( VALUE self, VALUE other )
|
|
5318
5139
|
RVec2 result;
|
5319
5140
|
rmReal f;
|
5320
5141
|
|
5321
|
-
|
5322
|
-
{
|
5323
|
-
case T_FIXNUM:
|
5324
|
-
case T_FLOAT:
|
5325
|
-
{
|
5142
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
5326
5143
|
TypedData_Get_Struct( self, RVec2, &RVec2_type, v );
|
5327
5144
|
f = NUM2DBL( other );
|
5328
5145
|
RVec2Scale( &result, v, f );
|
5329
5146
|
|
5330
5147
|
return RVec2_from_source( &result );
|
5331
|
-
}
|
5332
|
-
break;
|
5333
|
-
|
5334
|
-
default:
|
5335
|
-
{
|
5148
|
+
} else {
|
5336
5149
|
rb_raise( rb_eTypeError,
|
5337
5150
|
"RVec2#* : Unknown type %s.",
|
5338
5151
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other )
|
5339
5152
|
);
|
5340
5153
|
return Qnil;
|
5341
5154
|
}
|
5342
|
-
} /* End : switch( TYPE(other) ) */
|
5343
5155
|
}
|
5344
5156
|
|
5345
5157
|
/*
|
@@ -5441,7 +5253,7 @@ RVec2_op_assign_mult( VALUE self, VALUE other )
|
|
5441
5253
|
rmReal f;
|
5442
5254
|
|
5443
5255
|
#ifdef RMATH_ENABLE_ARGUMENT_CHECK
|
5444
|
-
if (
|
5256
|
+
if ( !RB_FLOAT_TYPE_P(other) && !RB_INTEGER_TYPE_P(other) )
|
5445
5257
|
{
|
5446
5258
|
rb_raise( rb_eTypeError,
|
5447
5259
|
"RVec2#*= : Unknown type %s.",
|
@@ -5528,43 +5340,30 @@ RVec3_initialize( int argc, VALUE* argv, VALUE self )
|
|
5528
5340
|
case 1:
|
5529
5341
|
{
|
5530
5342
|
VALUE arg = argv[0];
|
5531
|
-
|
5532
|
-
{
|
5533
|
-
case T_FIXNUM:
|
5534
|
-
case T_FLOAT:
|
5535
|
-
{
|
5343
|
+
if ( RB_FLOAT_TYPE_P(arg) || RB_INTEGER_TYPE_P(arg) ) {
|
5536
5344
|
/* convert to float */
|
5537
5345
|
rmReal f = NUM2DBL( arg );
|
5538
5346
|
RVec3SetElements( v, f,f,f );
|
5539
5347
|
return self;
|
5540
|
-
}
|
5541
|
-
|
5542
|
-
|
5543
|
-
|
5544
|
-
|
5545
|
-
|
5546
|
-
|
5547
|
-
|
5548
|
-
|
5549
|
-
|
5550
|
-
|
5551
|
-
|
5552
|
-
}
|
5553
|
-
else
|
5554
|
-
return Qnil;
|
5555
|
-
}
|
5556
|
-
break;
|
5557
|
-
|
5558
|
-
default:
|
5559
|
-
{
|
5348
|
+
} else {
|
5349
|
+
if ( TYPE( arg ) == T_DATA ) {
|
5350
|
+
if ( IsRVec3(arg) ) {
|
5351
|
+
/* Copy Constructor */
|
5352
|
+
RVec3* other;
|
5353
|
+
TypedData_Get_Struct( arg , RVec3, &RVec3_type, other );
|
5354
|
+
RVec3SetElements( v, other->x, other->y, other->z );
|
5355
|
+
return self;
|
5356
|
+
} else {
|
5357
|
+
return Qnil;
|
5358
|
+
}
|
5359
|
+
} else {
|
5560
5360
|
rb_raise( rb_eTypeError,
|
5561
5361
|
"RVec3_new : Unknown type %s.",
|
5562
5362
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
5563
5363
|
);
|
5564
5364
|
return Qnil;
|
5365
|
+
}
|
5565
5366
|
}
|
5566
|
-
break;
|
5567
|
-
} /* End : switch ( TYPE( arg ) ) */
|
5568
5367
|
} /* End : case 1 */
|
5569
5368
|
break;
|
5570
5369
|
|
@@ -5574,18 +5373,10 @@ RVec3_initialize( int argc, VALUE* argv, VALUE self )
|
|
5574
5373
|
int i;
|
5575
5374
|
for ( i = 0; i < argc; ++i )
|
5576
5375
|
{
|
5577
|
-
|
5578
|
-
{
|
5579
|
-
case T_FIXNUM:
|
5580
|
-
case T_FLOAT:
|
5581
|
-
{
|
5376
|
+
if ( RB_FLOAT_TYPE_P(argv[i]) || RB_INTEGER_TYPE_P(argv[i]) ) {
|
5582
5377
|
rmReal f = NUM2DBL( argv[i] );
|
5583
5378
|
v->e[i] = f;
|
5584
|
-
}
|
5585
|
-
break;
|
5586
|
-
|
5587
|
-
default:
|
5588
|
-
{
|
5379
|
+
} else {
|
5589
5380
|
rb_raise( rb_eTypeError,
|
5590
5381
|
"RVec3_new : Unknown type %s. at arg %d",
|
5591
5382
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self ),
|
@@ -5593,8 +5384,6 @@ RVec3_initialize( int argc, VALUE* argv, VALUE self )
|
|
5593
5384
|
);
|
5594
5385
|
return Qnil;
|
5595
5386
|
}
|
5596
|
-
break;
|
5597
|
-
}
|
5598
5387
|
} /* End : for ( i = 0; i < argc; ++i ) */
|
5599
5388
|
|
5600
5389
|
return self;
|
@@ -5679,21 +5468,12 @@ RVec3_coerce( VALUE self, VALUE other )
|
|
5679
5468
|
RVec3* v = NULL;
|
5680
5469
|
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
5681
5470
|
|
5682
|
-
|
5683
|
-
{
|
5684
|
-
case T_FLOAT:
|
5685
|
-
case T_FIXNUM:
|
5686
|
-
case T_BIGNUM:
|
5687
|
-
{
|
5471
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
5688
5472
|
/* 'other (op) RVec3'
|
5689
5473
|
* -> try again as 'RVec3 (op) other'
|
5690
5474
|
*/
|
5691
5475
|
return rb_ary_new3( 2, self, other );
|
5692
|
-
}
|
5693
|
-
break;
|
5694
|
-
|
5695
|
-
default:
|
5696
|
-
{
|
5476
|
+
} else {
|
5697
5477
|
rb_raise( rb_eTypeError,
|
5698
5478
|
"%s can't be coerced into %s",
|
5699
5479
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other ),
|
@@ -5701,8 +5481,6 @@ RVec3_coerce( VALUE self, VALUE other )
|
|
5701
5481
|
);
|
5702
5482
|
return Qnil;
|
5703
5483
|
}
|
5704
|
-
break;
|
5705
|
-
}
|
5706
5484
|
}
|
5707
5485
|
|
5708
5486
|
/*
|
@@ -6316,28 +6094,19 @@ RVec3_op_binary_mult( VALUE self, VALUE other )
|
|
6316
6094
|
RVec3 result;
|
6317
6095
|
rmReal f;
|
6318
6096
|
|
6319
|
-
|
6320
|
-
{
|
6321
|
-
case T_FIXNUM:
|
6322
|
-
case T_FLOAT:
|
6323
|
-
{
|
6097
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
6324
6098
|
TypedData_Get_Struct( self, RVec3, &RVec3_type, v );
|
6325
6099
|
f = NUM2DBL( other );
|
6326
6100
|
RVec3Scale( &result, v, f );
|
6327
6101
|
|
6328
6102
|
return RVec3_from_source( &result );
|
6329
|
-
}
|
6330
|
-
break;
|
6331
|
-
|
6332
|
-
default:
|
6333
|
-
{
|
6103
|
+
} else {
|
6334
6104
|
rb_raise( rb_eTypeError,
|
6335
6105
|
"RVec3#* : Unknown type %s.",
|
6336
6106
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other )
|
6337
6107
|
);
|
6338
6108
|
return Qnil;
|
6339
6109
|
}
|
6340
|
-
} /* End : switch( TYPE(other) ) */
|
6341
6110
|
}
|
6342
6111
|
|
6343
6112
|
/*
|
@@ -6439,7 +6208,7 @@ RVec3_op_assign_mult( VALUE self, VALUE other )
|
|
6439
6208
|
rmReal f;
|
6440
6209
|
|
6441
6210
|
#ifdef RMATH_ENABLE_ARGUMENT_CHECK
|
6442
|
-
if (
|
6211
|
+
if ( !RB_FLOAT_TYPE_P(other) && !RB_INTEGER_TYPE_P(other) )
|
6443
6212
|
{
|
6444
6213
|
rb_raise( rb_eTypeError,
|
6445
6214
|
"RVec3#*= : Unknown type %s.",
|
@@ -6526,51 +6295,36 @@ RVec4_initialize( int argc, VALUE* argv, VALUE self )
|
|
6526
6295
|
case 1:
|
6527
6296
|
{
|
6528
6297
|
VALUE arg = argv[0];
|
6529
|
-
|
6530
|
-
{
|
6531
|
-
case T_FIXNUM:
|
6532
|
-
case T_FLOAT:
|
6533
|
-
{
|
6298
|
+
if ( RB_FLOAT_TYPE_P(arg) || RB_INTEGER_TYPE_P(arg) ) {
|
6534
6299
|
/* convert to float */
|
6535
6300
|
rmReal f = NUM2DBL( arg );
|
6536
6301
|
RVec4SetElements( v, f,f,f,f );
|
6537
6302
|
return self;
|
6538
|
-
}
|
6539
|
-
|
6540
|
-
|
6541
|
-
|
6542
|
-
|
6543
|
-
|
6544
|
-
|
6545
|
-
|
6546
|
-
|
6547
|
-
|
6548
|
-
|
6549
|
-
|
6550
|
-
|
6551
|
-
|
6552
|
-
|
6553
|
-
|
6554
|
-
|
6555
|
-
|
6556
|
-
|
6557
|
-
|
6558
|
-
|
6559
|
-
|
6303
|
+
} else {
|
6304
|
+
if ( TYPE( arg ) == T_DATA ) {
|
6305
|
+
if ( IsRVec3(arg) ) {
|
6306
|
+
/* Create from RVec3 */
|
6307
|
+
RVec3* other;
|
6308
|
+
TypedData_Get_Struct( arg , RVec3, &RVec3_type, other );
|
6309
|
+
RVec4SetElements( v, other->x, other->y, other->z, 0.0f );
|
6310
|
+
return self;
|
6311
|
+
} else if ( IsRVec4(arg) ) {
|
6312
|
+
/* Copy Constructor */
|
6313
|
+
RVec4* other;
|
6314
|
+
TypedData_Get_Struct( arg , RVec4, &RVec4_type, other );
|
6315
|
+
RVec4SetElements( v, other->x, other->y, other->z, other->w );
|
6316
|
+
return self;
|
6317
|
+
} else {
|
6318
|
+
return Qnil;
|
6319
|
+
}
|
6320
|
+
} else {
|
6321
|
+
rb_raise( rb_eTypeError,
|
6322
|
+
"RVec4_new : Unknown type %s.",
|
6323
|
+
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
6324
|
+
);
|
6560
6325
|
return Qnil;
|
6326
|
+
}
|
6561
6327
|
}
|
6562
|
-
break;
|
6563
|
-
|
6564
|
-
default:
|
6565
|
-
{
|
6566
|
-
rb_raise( rb_eTypeError,
|
6567
|
-
"RVec4_new : Unknown type %s.",
|
6568
|
-
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self )
|
6569
|
-
);
|
6570
|
-
return Qnil;
|
6571
|
-
}
|
6572
|
-
break;
|
6573
|
-
} /* End : switch ( TYPE( arg ) ) */
|
6574
6328
|
} /* End : case 1 */
|
6575
6329
|
break;
|
6576
6330
|
|
@@ -6580,18 +6334,10 @@ RVec4_initialize( int argc, VALUE* argv, VALUE self )
|
|
6580
6334
|
int i;
|
6581
6335
|
for ( i = 0; i < argc; ++i )
|
6582
6336
|
{
|
6583
|
-
|
6584
|
-
{
|
6585
|
-
case T_FIXNUM:
|
6586
|
-
case T_FLOAT:
|
6587
|
-
{
|
6337
|
+
if ( RB_FLOAT_TYPE_P(argv[i]) || RB_INTEGER_TYPE_P(argv[i]) ) {
|
6588
6338
|
rmReal f = NUM2DBL( argv[i] );
|
6589
6339
|
v->e[i] = f;
|
6590
|
-
}
|
6591
|
-
break;
|
6592
|
-
|
6593
|
-
default:
|
6594
|
-
{
|
6340
|
+
} else {
|
6595
6341
|
rb_raise( rb_eTypeError,
|
6596
6342
|
"RVec4_new : Unknown type %s. at arg %d",
|
6597
6343
|
rb_special_const_p( self ) ? RSTRING_PTR( rb_inspect( self ) ) : rb_obj_classname( self ),
|
@@ -6599,8 +6345,6 @@ RVec4_initialize( int argc, VALUE* argv, VALUE self )
|
|
6599
6345
|
);
|
6600
6346
|
return Qnil;
|
6601
6347
|
}
|
6602
|
-
break;
|
6603
|
-
}
|
6604
6348
|
} /* End : for ( i = 0; i < argc; ++i ) */
|
6605
6349
|
|
6606
6350
|
return self;
|
@@ -6686,21 +6430,12 @@ RVec4_coerce( VALUE self, VALUE other )
|
|
6686
6430
|
RVec4* v = NULL;
|
6687
6431
|
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
6688
6432
|
|
6689
|
-
|
6690
|
-
{
|
6691
|
-
case T_FLOAT:
|
6692
|
-
case T_FIXNUM:
|
6693
|
-
case T_BIGNUM:
|
6694
|
-
{
|
6433
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
6695
6434
|
/* 'other (op) RVec4'
|
6696
6435
|
* -> try again as 'RVec4 (op) other'
|
6697
6436
|
*/
|
6698
6437
|
return rb_ary_new3( 2, self, other );
|
6699
|
-
}
|
6700
|
-
break;
|
6701
|
-
|
6702
|
-
default:
|
6703
|
-
{
|
6438
|
+
} else {
|
6704
6439
|
rb_raise( rb_eTypeError,
|
6705
6440
|
"%s can't be coerced into %s",
|
6706
6441
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other ),
|
@@ -6708,8 +6443,6 @@ RVec4_coerce( VALUE self, VALUE other )
|
|
6708
6443
|
);
|
6709
6444
|
return Qnil;
|
6710
6445
|
}
|
6711
|
-
break;
|
6712
|
-
}
|
6713
6446
|
}
|
6714
6447
|
|
6715
6448
|
/*
|
@@ -7215,28 +6948,19 @@ RVec4_op_binary_mult( VALUE self, VALUE other )
|
|
7215
6948
|
RVec4 result;
|
7216
6949
|
rmReal f;
|
7217
6950
|
|
7218
|
-
|
7219
|
-
{
|
7220
|
-
case T_FIXNUM:
|
7221
|
-
case T_FLOAT:
|
7222
|
-
{
|
6951
|
+
if ( RB_FLOAT_TYPE_P(other) || RB_INTEGER_TYPE_P(other) ) {
|
7223
6952
|
TypedData_Get_Struct( self, RVec4, &RVec4_type, v );
|
7224
6953
|
f = NUM2DBL( other );
|
7225
6954
|
RVec4Scale( &result, v, f );
|
7226
6955
|
|
7227
6956
|
return RVec4_from_source( &result );
|
7228
|
-
}
|
7229
|
-
break;
|
7230
|
-
|
7231
|
-
default:
|
7232
|
-
{
|
6957
|
+
} else {
|
7233
6958
|
rb_raise( rb_eTypeError,
|
7234
6959
|
"RVec4#* : Unknown type %s.",
|
7235
6960
|
rb_special_const_p( other ) ? RSTRING_PTR( rb_inspect( other ) ) : rb_obj_classname( other )
|
7236
6961
|
);
|
7237
6962
|
return Qnil;
|
7238
6963
|
}
|
7239
|
-
} /* End : switch( TYPE(other) ) */
|
7240
6964
|
}
|
7241
6965
|
|
7242
6966
|
/*
|
@@ -7338,7 +7062,7 @@ RVec4_op_assign_mult( VALUE self, VALUE other )
|
|
7338
7062
|
rmReal f;
|
7339
7063
|
|
7340
7064
|
#ifdef RMATH_ENABLE_ARGUMENT_CHECK
|
7341
|
-
if (
|
7065
|
+
if ( !RB_FLOAT_TYPE_P(other) && !RB_INTEGER_TYPE_P(other) )
|
7342
7066
|
{
|
7343
7067
|
rb_raise( rb_eTypeError,
|
7344
7068
|
"RVec4#*= : Unknown type %s.",
|
@@ -7820,7 +7544,7 @@ Init_rmath3d()
|
|
7820
7544
|
|
7821
7545
|
/*
|
7822
7546
|
RMath : Ruby math module for 3D Applications
|
7823
|
-
Copyright (c) 2008- vaiorabbit <http://twitter.com/vaiorabbit>
|
7547
|
+
Copyright (c) 2008-2017 vaiorabbit <http://twitter.com/vaiorabbit>
|
7824
7548
|
|
7825
7549
|
This software is provided 'as-is', without any express or implied
|
7826
7550
|
warranty. In no event will the authors be held liable for any damages
|