Use template for object rotation functions

This commit is contained in:
Kp 2016-01-09 16:38:13 +00:00
parent 988df1cc42
commit d6359d0eb7
3 changed files with 38 additions and 26 deletions

View file

@ -33,12 +33,6 @@ namespace dsx {
int ObjectSelectNextInMine(void);
int ObjectSelectPrevInMine(void);
int ObjectDecreaseBankBig();
int ObjectIncreaseBankBig();
int ObjectDecreasePitchBig();
int ObjectIncreasePitchBig();
int ObjectDecreaseHeadingBig();
int ObjectIncreaseHeadingBig();
int ObjectFlipObject();
}
#endif

View file

@ -230,12 +230,26 @@ int ObjectMoveNearer();
int ObjectMoveFurther();
int ObjectSelectNextinSegment();
int ObjectSelectNextType();
int ObjectDecreaseBank();
int ObjectIncreaseBank();
int ObjectDecreasePitch();
int ObjectIncreasePitch();
int ObjectDecreaseHeading();
int ObjectIncreaseHeading();
template <int p, int b, int h>
int ObjectChangeRotation();
#define ROTATION_UNIT (4096/4)
#define ObjectDecreaseBank ObjectChangeRotation<0, -ROTATION_UNIT, 0>
#define ObjectIncreaseBank ObjectChangeRotation<0, ROTATION_UNIT, 0>
#define ObjectDecreasePitch ObjectChangeRotation<-ROTATION_UNIT, 0, 0>
#define ObjectIncreasePitch ObjectChangeRotation<ROTATION_UNIT, 0, 0>
#define ObjectDecreaseHeading ObjectChangeRotation<0, 0, -ROTATION_UNIT>
#define ObjectIncreaseHeading ObjectChangeRotation<0, 0, ROTATION_UNIT>
#define ObjectDecreaseBankBig ObjectChangeRotation<0, -(ROTATION_UNIT*4), 0>
#define ObjectIncreaseBankBig ObjectChangeRotation<0, (ROTATION_UNIT*4), 0>
#define ObjectDecreasePitchBig ObjectChangeRotation<-(ROTATION_UNIT*4), 0, 0>
#define ObjectIncreasePitchBig ObjectChangeRotation<(ROTATION_UNIT*4), 0, 0>
#define ObjectDecreaseHeadingBig ObjectChangeRotation<0, 0, -(ROTATION_UNIT*4)>
#define ObjectIncreaseHeadingBig ObjectChangeRotation<0, 0, (ROTATION_UNIT*4)>
int ObjectResetObject();
}
#endif

View file

@ -62,8 +62,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#define OBJ_SCALE (F1_0/2)
#define OBJ_DEL_SIZE (F1_0/2)
#define ROTATION_UNIT (4096/4)
static void show_objects_in_segment(const vcsegptr_t sp)
{
range_for (const auto i, objects_in(sp))
@ -720,19 +718,25 @@ int ObjectFlipObject()
return 1;
}
int ObjectDecreaseBank() {return rotate_object(Cur_object_index, 0, -ROTATION_UNIT, 0);}
int ObjectIncreaseBank() {return rotate_object(Cur_object_index, 0, ROTATION_UNIT, 0);}
int ObjectDecreasePitch() {return rotate_object(Cur_object_index, -ROTATION_UNIT, 0, 0);}
int ObjectIncreasePitch() {return rotate_object(Cur_object_index, ROTATION_UNIT, 0, 0);}
int ObjectDecreaseHeading() {return rotate_object(Cur_object_index, 0, 0, -ROTATION_UNIT);}
int ObjectIncreaseHeading() {return rotate_object(Cur_object_index, 0, 0, ROTATION_UNIT);}
template <int p, int b, int h>
int ObjectChangeRotation()
{
return rotate_object(vobjptridx(Cur_object_index), p, b, h);
}
int ObjectDecreaseBankBig() {return rotate_object(Cur_object_index, 0, -(ROTATION_UNIT*4), 0);}
int ObjectIncreaseBankBig() {return rotate_object(Cur_object_index, 0, (ROTATION_UNIT*4), 0);}
int ObjectDecreasePitchBig() {return rotate_object(Cur_object_index, -(ROTATION_UNIT*4), 0, 0);}
int ObjectIncreasePitchBig() {return rotate_object(Cur_object_index, (ROTATION_UNIT*4), 0, 0);}
int ObjectDecreaseHeadingBig() {return rotate_object(Cur_object_index, 0, 0, -(ROTATION_UNIT*4));}
int ObjectIncreaseHeadingBig() {return rotate_object(Cur_object_index, 0, 0, (ROTATION_UNIT*4));}
template int ObjectDecreaseBank();
template int ObjectIncreaseBank();
template int ObjectDecreasePitch();
template int ObjectIncreasePitch();
template int ObjectDecreaseHeading();
template int ObjectIncreaseHeading();
template int ObjectDecreaseBankBig();
template int ObjectIncreaseBankBig();
template int ObjectDecreasePitchBig();
template int ObjectIncreasePitchBig();
template int ObjectDecreaseHeadingBig();
template int ObjectIncreaseHeadingBig();
// -----------------------------------------------------------------------------------------------------
// Move object around based on clicks in 2d screen.