| | 163 | case MJ_DEC_VEC3: {\ |
| | 164 | double d = ur_decimal(res); \ |
| | 165 | ur_initType(res, UT_VEC3); \ |
| | 166 | res->vec3.xyz[0] = d OP tos->vec3.xyz[0]; \ |
| | 167 | res->vec3.xyz[1] = d OP tos->vec3.xyz[1]; \ |
| | 168 | res->vec3.xyz[2] = d OP tos->vec3.xyz[2]; \ |
| | 169 | } break; \ |
| | 170 | case MJ_VEC3_DEC: \ |
| | 171 | res->vec3.xyz[0] = res->vec3.xyz[0] OP ur_decimal(tos); \ |
| | 172 | res->vec3.xyz[1] = res->vec3.xyz[1] OP ur_decimal(tos); \ |
| | 173 | res->vec3.xyz[2] = res->vec3.xyz[2] OP ur_decimal(tos); \ |
| | 174 | break; \ |
| | 175 | case MJ_VEC3_VEC3: \ |
| | 176 | res->vec3.xyz[0] = res->vec3.xyz[0] OP tos->vec3.xyz[0]; \ |
| | 177 | res->vec3.xyz[1] = res->vec3.xyz[1] OP tos->vec3.xyz[1]; \ |
| | 178 | res->vec3.xyz[2] = res->vec3.xyz[2] OP tos->vec3.xyz[2]; \ |
| | 179 | break; \ |
| | 291 | } |
| | 292 | } |
| | 293 | |
| | 294 | |
| | 295 | // (number number -- min) |
| | 296 | UR_CALL( uc_minimum ) |
| | 297 | { |
| | 298 | UCell* res; |
| | 299 | UR_S_DROP; |
| | 300 | res = UR_TOS; |
| | 301 | |
| | 302 | switch( _mathJumpIndex(res, tos) ) |
| | 303 | { |
| | 304 | case MJ_INT_INT: |
| | 305 | if( ur_int(res) > ur_int(tos) ) |
| | 306 | ur_int(res) = ur_int(tos); |
| | 307 | break; |
| | 308 | case MJ_INT_DEC: |
| | 309 | { |
| | 310 | double d = ur_decimal(res); |
| | 311 | if( d > ur_decimal(tos) ) |
| | 312 | { |
| | 313 | ur_initType(res, UT_DECIMAL); |
| | 314 | ur_decimal(res) = ur_decimal(tos); |
| | 315 | } |
| | 316 | } |
| | 317 | break; |
| | 318 | case MJ_DEC_INT: |
| | 319 | { |
| | 320 | double d = ur_decimal(tos); |
| | 321 | if( ur_decimal(res) > d ) |
| | 322 | ur_decimal(res) = d; |
| | 323 | } |
| | 324 | break; |
| | 325 | case MJ_DEC_DEC: |
| | 326 | if( ur_decimal(res) > ur_decimal(tos) ) |
| | 327 | ur_decimal(res) = ur_decimal(tos); |
| | 328 | break; |
| | 329 | case MJ_VEC3_VEC3: |
| | 330 | if( res->vec3.xyz[0] > tos->vec3.xyz[0] ) |
| | 331 | res->vec3.xyz[0] = tos->vec3.xyz[0]; |
| | 332 | if( res->vec3.xyz[1] > tos->vec3.xyz[1] ) |
| | 333 | res->vec3.xyz[1] = tos->vec3.xyz[1]; |
| | 334 | if( res->vec3.xyz[2] > tos->vec3.xyz[2] ) |
| | 335 | res->vec3.xyz[2] = tos->vec3.xyz[2]; |
| | 336 | break; |
| | 337 | default: |
| | 338 | ur_throwErr( ur_thread, UR_EX_DATATYPE, |
| | 339 | "Invalid type for 'minimum" ); |
| | 340 | break; |
| | 341 | } |
| | 342 | } |
| | 343 | |
| | 344 | |
| | 345 | // (number number -- max) |
| | 346 | UR_CALL( uc_maximum ) |
| | 347 | { |
| | 348 | UCell* res; |
| | 349 | UR_S_DROP; |
| | 350 | res = UR_TOS; |
| | 351 | |
| | 352 | switch( _mathJumpIndex(res, tos) ) |
| | 353 | { |
| | 354 | case MJ_INT_INT: |
| | 355 | if( ur_int(res) < ur_int(tos) ) |
| | 356 | ur_int(res) = ur_int(tos); |
| | 357 | break; |
| | 358 | case MJ_INT_DEC: |
| | 359 | { |
| | 360 | double d = ur_decimal(res); |
| | 361 | if( d < ur_decimal(tos) ) |
| | 362 | { |
| | 363 | ur_initType(res, UT_DECIMAL); |
| | 364 | ur_decimal(res) = ur_decimal(tos); |
| | 365 | } |
| | 366 | } |
| | 367 | break; |
| | 368 | case MJ_DEC_INT: |
| | 369 | { |
| | 370 | double d = ur_decimal(tos); |
| | 371 | if( ur_decimal(res) < d ) |
| | 372 | ur_decimal(res) = d; |
| | 373 | } |
| | 374 | break; |
| | 375 | case MJ_DEC_DEC: |
| | 376 | if( ur_decimal(res) < ur_decimal(tos) ) |
| | 377 | ur_decimal(res) = ur_decimal(tos); |
| | 378 | break; |
| | 379 | case MJ_VEC3_VEC3: |
| | 380 | if( res->vec3.xyz[0] < tos->vec3.xyz[0] ) |
| | 381 | res->vec3.xyz[0] = tos->vec3.xyz[0]; |
| | 382 | if( res->vec3.xyz[1] < tos->vec3.xyz[1] ) |
| | 383 | res->vec3.xyz[1] = tos->vec3.xyz[1]; |
| | 384 | if( res->vec3.xyz[2] < tos->vec3.xyz[2] ) |
| | 385 | res->vec3.xyz[2] = tos->vec3.xyz[2]; |
| | 386 | break; |
| | 387 | default: |
| | 388 | ur_throwErr( ur_thread, UR_EX_DATATYPE, |
| | 389 | "Invalid type for 'maximum" ); |
| | 390 | break; |