Skip to content

Commit

Permalink
Support for weapon voxel models
Browse files Browse the repository at this point in the history
commit 224743d
Merge: e2ddb3f bcbc382
Author: Alaux <73968015+MrAlaux@users.noreply.github.com>
Date:   Thu Jan 9 22:22:12 2025 -0300

    Merge branch 'master' into weapon_voxels

commit e2ddb3f
Merge: 845b3c5 5cb10df
Author: Alaux <73968015+MrAlaux@users.noreply.github.com>
Date:   Fri Aug 23 17:45:02 2024 -0300

    Merge branch 'master' into weapon_voxels

commit 845b3c5
Author: Alaux <73968015+MrAlaux@users.noreply.github.com>
Date:   Wed Jul 31 06:04:38 2024 -0300

    Remove hardcoded height adjustment, add a comment

commit 347637b
Merge: e5ce342 19975d7
Author: Alaux <73968015+MrAlaux@users.noreply.github.com>
Date:   Wed Jul 31 04:48:40 2024 -0300

    Merge branch 'master' into weapon_voxels

commit e5ce342
Author: Alaux <73968015+MrAlaux@users.noreply.github.com>
Date:   Tue Jul 30 08:52:43 2024 -0300

    Support for weapon voxels
  • Loading branch information
MrAlaux committed Jan 17, 2025
1 parent 651f389 commit 1d11b97
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## New Features

- **Support for weapon voxel models**
- **_'RIOTMODE'_** cheat, to make enemies attack all sentient entities
- **_Vertical Target Lock-on_** setting
- **_Message Fadeout_** setting
Expand All @@ -10,7 +11,7 @@

## Changes

- **Merged changes from [Woof! post-15.0.1]**, note:
- **Merged changes from [Woof! 15.0.1](https://github.com/fabiangreffrath/woof/releases/tag/woof_15.1.0)**, note:
- Replaced `fullscreen_hud_type` with `use_nughud`, with the NUGHUD now replacing the second-to-last HUD
- Removed `fuzzdark_mode` in favor of Woof!'s `fuzzmode` (_Refraction_ is equivalent to _Selective Fuzz Darkening_)
- Removed `comp_blazing2`; its functionality has been integrated into `comp_blazing`
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ For these settings, their CVAR names are provided alongside the _CFG-only_ label
- Application while firing determined by the CFG-only `weapon_inertia_fire` CVAR
- **_Weapon Squat Upon Landing_** setting [p.f. Crispy Doom]
- **_Translucent Flashes_** setting (translucency determined by the CFG-only `translucent_pspr_pct` CVAR) [i.b. Crispy Doom]
- **Support for weapon voxel models**
- **"Correct" first-person-sprite centering** setting, to toggle the 1px misalignment of first-person sprites (CFG-only: `sx_fix`)

### Status Bar/HUD
Expand Down
9 changes: 9 additions & 0 deletions src/r_things.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ static size_t num_vissprite, num_vissprite_alloc, num_vissprite_ptrs;

static mobj_t **nearby_sprites = NULL;

// [Nugget]
vissprite_t *R_GetLastVisSprite(void)
{
return &vissprites[num_vissprite - 1];
}

//
// R_InitSprites
// Called at program start.
Expand Down Expand Up @@ -851,6 +857,9 @@ void R_DrawPSprite (pspdef_t *psp, boolean translucent) // [Nugget] Translucent
vissprite_t *vis;
vissprite_t avis;

// [Nugget]
if (VX_DrawWeaponVoxel(psp, translucent)) { return; }

// decide which patch to use

#ifdef RANGECHECK
Expand Down
2 changes: 2 additions & 0 deletions src/r_things.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void R_InitSpritesRes(void);

void R_NearbySprites(void);

vissprite_t *R_GetLastVisSprite(void); // [Nugget]

#endif

//----------------------------------------------------------------------------
Expand Down
71 changes: 71 additions & 0 deletions src/r_voxel.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include "w_wad.h"
#include "z_zone.h"

// [Nugget]
#include "wi_stuff.h"

static boolean voxels_found;
boolean voxels_rendering, default_voxels_rendering;

Expand Down Expand Up @@ -1083,3 +1086,71 @@ void VX_DrawVoxel (vissprite_t * spr)

VX_RecursiveDraw (spr, 0, 0, v->x_size, v->y_size);
}

// [Nugget]
boolean VX_DrawWeaponVoxel (pspdef_t *psp, boolean translucent)
{
if (STRICTMODE(hide_weapon)
|| R_GetChasecamOn() // Chasecam
|| R_GetFreecamOn() // Freecam
|| (WI_UsingAltInterpic() && (gamestate == GS_INTERMISSION))) // Alt. intermission background
{
return false;
}

mobj_t thing = {0};

fixed_t sx2, sy2, wix, wiy;

if (uncapped && oldleveltime < leveltime)
{
sx2 = LerpFixed(psp->oldsx2, psp->sx2);
sy2 = LerpFixed(psp->oldsy2, psp->sy2);
wix = LerpFixed(psp->oldwix, psp->wix);
wiy = LerpFixed(psp->oldwiy, psp->wiy);
}
else {
sx2 = psp->sx2;
sy2 = psp->sy2;
wix = psp->wix;
wiy = psp->wiy;
}

fixed_t x = sx2,
y = sy2 - 32*FRACUNIT;

if (STRICTMODE(weapon_inertia))
{
x += wix / 2;
y += wiy / 2;
}

x /= 5;
y /= 5;

thing.x = thing.oldx = viewx + FixedMul(x, finesine[viewangle >> ANGLETOFINESHIFT]);
thing.y = thing.oldy = viewy - FixedMul(x, finecosine[viewangle >> ANGLETOFINESHIFT]);
thing.z = thing.oldz = viewz - y;

thing.angle = thing.oldangle = viewangle - ANG90;

thing.sprite = psp->state->sprite;
thing.frame = psp->state->frame;

if (translucent)
{ thing.flags |= MF_TRANSLUCENT; }

if (POWER_RUNOUT(viewplayer->powers[pw_invisibility]) && !beta_emulation)
{ thing.flags |= MF_SHADOW; }

// Albeit unused, `R_ProjectVoxel()` accesses `heightsec`
sector_t sector = {0};
subsector_t sub = { .sector = &sector };
thing.subsector = &sub;

if (!VX_ProjectVoxel(&thing))
{ return false; }

VX_DrawVoxel(R_GetLastVisSprite());
return true;
}
2 changes: 2 additions & 0 deletions src/r_voxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ boolean VX_ProjectVoxel (struct mobj_s * thing);
struct vissprite_s;
void VX_DrawVoxel (struct vissprite_s * vis);

boolean VX_DrawWeaponVoxel (struct pspdef_s *psp, boolean translucent); // [Nugget]

extern boolean voxels_rendering, default_voxels_rendering;

void VX_IncreaseMaxDist (void);
Expand Down

0 comments on commit 1d11b97

Please sign in to comment.