Merge pull request #1275 from fabiangreffrath/voxel_rotate

weapon pickup voxels spinning in place
This commit is contained in:
Fabian Greffrath 2023-11-22 12:14:33 +01:00 committed by GitHub
commit bf45792cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,6 +53,8 @@ struct Voxel
static struct Voxel *** all_voxels;
#define VX_ITEM_ROTATION_ANGLE (4 * ANG1)
static int vx_rotate_items = 1;
@ -393,16 +395,57 @@ static int VX_RotateModeForThing (mobj_t * thing)
break;
}
// in most maps, items don't have "nice" facing directions, so this
// option orientates them in a way similar to sprites.
if (vx_rotate_items && (thing->flags & MF_SPECIAL))
return 1;
if (vx_rotate_items)
{
switch (thing->sprite)
{
case SPR_SHOT:
case SPR_MGUN:
case SPR_LAUN:
case SPR_PLAS:
case SPR_BFUG:
case SPR_CSAW:
case SPR_SGN2:
return 3;
default:
break;
}
// in most maps, items don't have "nice" facing directions, so this
// option orientates them in a way similar to sprites.
if (thing->flags & MF_SPECIAL)
return 1;
}
// use existing angle
return 0;
}
static angle_t VX_GetItemRotationAngle (void)
{
static int oldgametic = -1;
static angle_t oldangle, newangle;
if (oldgametic < gametic)
{
oldangle = newangle;
newangle = leveltime * VX_ITEM_ROTATION_ANGLE;
oldgametic = gametic;
}
if (uncapped)
{
return R_InterpolateAngle (oldangle, newangle, fractionaltic);
}
else
{
return newangle;
}
}
static boolean VX_CheckFrustum (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2,
fixed_t x3, fixed_t y3, fixed_t x4, fixed_t y4)
{
@ -534,6 +577,10 @@ boolean VX_ProjectVoxel (mobj_t * thing)
case 2:
angle = R_PointToAngle (gx, gy) + ANG180;
break;
case 3:
angle = VX_GetItemRotationAngle ();
break;
}
angle_t ang2 = ANG180 - viewangle + angle;