Skip to content

Commit

Permalink
- add flag +BILLBOARDFACECAMERA - renders actor billboard to always f…
Browse files Browse the repository at this point in the history
…ace the camera

tested with this code snippet:
```
class ZombieManFaceCamera : Zombieman replaces Zombieman
{
	default
	{
		+BILLBOARDFACECAMERA;
	}
}
```
  • Loading branch information
madame-rachelle committed Dec 8, 2023
1 parent 43c70cd commit 3caa624
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/playsim/actor.h
Expand Up @@ -481,21 +481,22 @@ enum ActorRenderFlag
RF_MASKROTATION = 0x00200000, // [MC] Only draw the actor when viewed from a certain angle range.
RF_ABSMASKANGLE = 0x00400000, // [MC] The mask rotation does not offset by the actor's angle.
RF_ABSMASKPITCH = 0x00800000, // [MC] The mask rotation does not offset by the actor's pitch.
RF_INTERPOLATEANGLES = 0x01000000, // [MC] Allow interpolation of the actor's angle, pitch and roll.
RF_INTERPOLATEANGLES = 0x01000000, // [MC] Allow interpolation of the actor's angle, pitch and roll.
RF_MAYBEINVISIBLE = 0x02000000,
RF_DONTINTERPOLATE = 0x04000000, // no render interpolation ever!

RF_SPRITEFLIP = 0x08000000, // sprite flipped on x-axis
RF_ZDOOMTRANS = 0x10000000, // is not normally transparent in Vanilla Doom
RF_CASTSPRITESHADOW = 0x20000000, // actor will cast a sprite shadow
RF_NOINTERPOLATEVIEW = 0x40000000, // don't interpolate the view next frame if this actor is a camera.
RF_NOSPRITESHADOW = 0x80000000, // actor will not cast a sprite shadow
RF_NOSPRITESHADOW = 0x80000000, // actor will not cast a sprite shadow
};

enum ActorRenderFlag2
{
RF2_INVISIBLEINMIRRORS = 0x0001, // [Nash] won't render in mirrors
RF2_ONLYVISIBLEINMIRRORS = 0x0002, // [Nash] only renders in mirrors
RF2_BILLBOARDFACECAMERA = 0x0004, // Sprite billboard face camera (override gl_billboard_faces_camera)
};

// This translucency value produces the closest match to Heretic's TINTTAB.
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_drawlist.cpp
Expand Up @@ -523,7 +523,7 @@ void HWDrawList::SortSpriteIntoWall(HWDrawInfo *di, SortNode * head,SortNode * s
const bool drawWithXYBillboard = ((ss->particle && gl_billboard_particles) || (!(ss->actor && ss->actor->renderflags & RF_FORCEYBILLBOARD)
&& (gl_billboard_mode == 1 || (ss->actor && ss->actor->renderflags & RF_FORCEXYBILLBOARD))));

const bool drawBillboardFacingCamera = gl_billboard_faces_camera;
const bool drawBillboardFacingCamera = gl_billboard_faces_camera || (ss->actor && ss->actor->renderflags2 & RF2_BILLBOARDFACECAMERA);
// [Nash] has +ROLLSPRITE
const bool rotated = (ss->actor != nullptr && ss->actor->renderflags & (RF_ROLLSPRITE | RF_WALLSPRITE | RF_FLATSPRITE));

Expand Down
6 changes: 4 additions & 2 deletions src/rendering/hwrenderer/scene/hw_sprites.cpp
Expand Up @@ -386,7 +386,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp)
//&& di->mViewActor != nullptr
&& (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD))));

const bool drawBillboardFacingCamera = gl_billboard_faces_camera;
const bool drawBillboardFacingCamera = gl_billboard_faces_camera || !!(actor->renderflags2 & RF2_BILLBOARDFACECAMERA);

This comment has been minimized.

Copy link
@MajorCooke

MajorCooke Dec 8, 2023

Contributor

The lack of null pointer check here is causing some mods to crash.

// [Nash] has +ROLLSPRITE
const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE);

Expand Down Expand Up @@ -1135,7 +1135,9 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
// This is a non-translucent sprite (i.e. STYLE_Normal or equivalent)
trans = 1.f;

if (!gl_sprite_blend || modelframe || (thing->renderflags & (RF_FLATSPRITE | RF_WALLSPRITE)) || gl_billboard_faces_camera)
if (!gl_sprite_blend || modelframe ||
(thing->renderflags & (RF_FLATSPRITE | RF_WALLSPRITE)) || gl_billboard_faces_camera ||
thing->renderflags2 & RF2_BILLBOARDFACECAMERA)
{
RenderStyle.SrcAlpha = STYLEALPHA_One;
RenderStyle.DestAlpha = STYLEALPHA_Zero;
Expand Down
1 change: 1 addition & 0 deletions src/scripting/thingdef_data.cpp
Expand Up @@ -378,6 +378,7 @@ static FFlagDef ActorFlagDefs[]=
DEFINE_FLAG(RF, NOSPRITESHADOW, AActor, renderflags),
DEFINE_FLAG(RF2, INVISIBLEINMIRRORS, AActor, renderflags2),
DEFINE_FLAG(RF2, ONLYVISIBLEINMIRRORS, AActor, renderflags2),
DEFINE_FLAG(RF2, BILLBOARDFACECAMERA, AActor, renderflags2),

// Bounce flags
DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags),
Expand Down

6 comments on commit 3caa624

@RicardoLuis0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between this and +ForceXYBillboard?

@madame-rachelle
Copy link
Collaborator Author

@madame-rachelle madame-rachelle commented on 3caa624 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForceXYBillboard is more for ball sprites and such.

This one just enables the "sprite faces camera" as a per-sprite (mod-defined) option, via an actor flag.

To be clear, normally sprites face the camera angle, which makes them appear more consistent when they get to the edges of the camera. This (and the related menu option) makes it so they directly point to the camera's position, instead.

@MajorCooke
Copy link
Contributor

@MajorCooke MajorCooke commented on 3caa624 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a +NoFaceCamera variant that does the opposite? That'd be really appreciated.

This will allow modders full control over what they want to allow to face the camera and not.

@madame-rachelle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is doable.

@madame-rachelle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RicardoLuis0

Camera in these screenshots is looking down

⬇️ +ForceXYBillboard ⬇️
image

⬇️ +BillboardFaceCamera ⬇️
image

@MajorCooke
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is doable.

Looking forward to it!

Please sign in to comment.