- Made AActor's xscale and yscale properties full precision fixed point

so now larger scales than 4 can be done.


SVN r381 (trunk)
This commit is contained in:
Christoph Oelckers 2006-11-14 16:54:02 +00:00
parent f6f15ba764
commit 1502215009
24 changed files with 71 additions and 63 deletions

View file

@ -1,3 +1,7 @@
November 14, 2006 (Changes by Graf Zahl)
- Made AActor's xscale and yscale properties full precision fixed point
so now larger scales than 4 can be done.
November 10, 2006 (Changes by Graf Zahl)
- Added a check to P_CheckMissileSpawn to decrease the monster counter
if it was called for spawning a monster with A_CustomMissile.

View file

@ -605,7 +605,7 @@ public:
angle_t angle;
WORD sprite; // used to find patch_t and flip value
BYTE frame; // sprite frame to draw
BYTE xscale, yscale; // Scaling values; 63 is normal size
fixed_t scaleX, scaleY; // Scaling values; FRACUNIT is normal size
BYTE RenderStyle; // Style to draw this actor with
DWORD renderflags; // Different rendering flags
WORD picnum; // Draw this instead of sprite if != 0xffff

View file

@ -2101,7 +2101,7 @@ void AM_drawThings (int _color)
}
static void DrawMarker (FTexture *tex, fixed_t x, fixed_t y, int yadjust,
INTBOOL flip, int xscale, int yscale, int translation, fixed_t alpha, DWORD alphacolor, int renderstyle)
INTBOOL flip, fixed_t xscale, fixed_t yscale, int translation, fixed_t alpha, DWORD alphacolor, int renderstyle)
{
if (tex == NULL || tex->UseType == FTexture::TEX_Null)
{
@ -2112,8 +2112,8 @@ static void DrawMarker (FTexture *tex, fixed_t x, fixed_t y, int yadjust,
AM_rotatePoint (&x, &y);
}
screen->DrawTexture (tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y,
DTA_DestWidth, MulScale6 (tex->GetScaledWidth() * CleanXfac, xscale),
DTA_DestHeight, MulScale6 (tex->GetScaledHeight() * CleanYfac, yscale),
DTA_DestWidth, MulScale16 (tex->GetScaledWidth() * CleanXfac, xscale),
DTA_DestHeight, MulScale16 (tex->GetScaledHeight() * CleanYfac, yscale),
DTA_ClipTop, f_y,
DTA_ClipBottom, f_y + f_h,
DTA_ClipLeft, f_x,
@ -2190,7 +2190,7 @@ void AM_drawAuthorMarkers ()
if (mark->args[1] == 0 || (mark->args[1] == 1 && marked->Sector->MoreFlags & SECF_DRAWN))
{
DrawMarker (tex, marked->x >> FRACTOMAPBITS, marked->y >> FRACTOMAPBITS, 0,
flip, mark->xscale+1, mark->yscale+1, mark->Translation,
flip, mark->scaleX, mark->scaleY, mark->Translation,
mark->alpha, mark->alphacolor, mark->RenderStyle);
}
marked = mark->args[0] != 0 ? it.Next() : NULL;

View file

@ -64,6 +64,7 @@
#include "v_palette.h"
#include "a_sharedglobal.h"
#include "thingdef.h"
#include "vectors.h"
// [SO] Just the way Randy said to do it :)
// [RH] Made this CVAR_SERVERINFO
@ -799,8 +800,7 @@ static int PatchThing (int thingy)
}
else if (stricmp (Line1, "Scale") == 0)
{
info->xscale = clamp ((int)(atof (Line2) * 64), 1, 256) - 1;
info->yscale = clamp ((int)(atof (Line2) * 64), 1, 256) - 1;
info->scaleY = info->scaleX = clamp<fixed_t> (FLOAT2FIXED(atof (Line2)), 1, 256*FRACUNIT);
}
else if (stricmp (Line1, "Decal") == 0)
{

View file

@ -663,7 +663,7 @@ void D_ReadUserInfoStrings (int i, BYTE **stream, bool update)
GetDefaultByType (players[i].cls)->SpawnState->sprite.index)
{ // Only change the sprite if the player is using a standard one
players[i].mo->sprite = skins[info->skin].sprite;
players[i].mo->xscale = players[i].mo->yscale = skins[info->skin].scale;
players[i].mo->scaleX = players[i].mo->scaleY = skins[info->skin].Scale;
}
}
// Rebuild translation in case the new skin uses a different range

View file

@ -51,6 +51,7 @@
#include "decallib.h"
#include "i_system.h"
#include "thingdef.h"
#include "vectors.h"
// MACROS ------------------------------------------------------------------
@ -668,7 +669,7 @@ static void ParseInsideDecoration (FActorInfo *info, AActor *defaults,
else if (SC_Compare ("Scale"))
{
SC_MustGetFloat ();
defaults->xscale = defaults->yscale = clamp (int(sc_Float * 64.f), 1, 256) - 1;
defaults->scaleX = defaults->scaleY = FLOAT2FIXED(sc_Float);
}
else if (SC_Compare ("RenderStyle"))
{

View file

@ -238,8 +238,8 @@ void AScriptedMarine::BeginPlay ()
AActor * playerdef = GetDefaultByName("DoomPlayer");
if (playerdef != NULL)
{
xscale = playerdef->xscale;
yscale = playerdef->yscale;
scaleX = playerdef->scaleX;
scaleY = playerdef->scaleY;
}
}
@ -976,13 +976,13 @@ void AScriptedMarine::SetSprite (const PClass *source)
// Copy the standard player's scaling
AActor * playerdef = GetDefaultByName("DoomPlayer");
if (playerdef == NULL) playerdef = GetDefaultByType(RUNTIME_CLASS(AScriptedMarine));
xscale = playerdef->xscale;
yscale = playerdef->yscale;
scaleX = playerdef->scaleX;
scaleY = playerdef->scaleY;
}
else
{ // Use the same sprite the passed class spawns with
SpriteOverride = sprite = GetDefaultByType (source)->SpawnState->sprite.index;
xscale = GetDefaultByType(source)->xscale;
yscale = GetDefaultByType(source)->yscale;
scaleX = GetDefaultByType(source)->scaleX;
scaleY = GetDefaultByType(source)->scaleY;
}
}

View file

@ -29,7 +29,7 @@ FState AArtiBoostArmor::States[] =
};
IMPLEMENT_ACTOR (AArtiBoostArmor, Hexen, 8041, 22)
PROP_Flags (MF_SPECIAL)
PROP_Flags (MF_SPECIAL|MF_COUNTITEM)
PROP_Flags2 (MF2_FLOATBOB)
PROP_SpawnState (0)
PROP_Inventory_DefMaxAmount

View file

@ -44,7 +44,7 @@ FState AArtiHealingRadius::States[] =
};
IMPLEMENT_ACTOR (AArtiHealingRadius, Hexen, 10120, 0)
PROP_Flags (MF_SPECIAL)
PROP_Flags (MF_SPECIAL|MF_COUNTITEM)
PROP_Flags2 (MF2_FLOATBOB)
PROP_SpawnState (0)
PROP_Inventory_DefMaxAmount

View file

@ -25,7 +25,7 @@ FState AArtiDarkServant::States[] =
};
IMPLEMENT_ACTOR (AArtiDarkServant, Hexen, 86, 16)
PROP_Flags (MF_SPECIAL)
PROP_Flags (MF_SPECIAL|MF_COUNTITEM)
PROP_Flags2 (MF2_FLOATBOB)
PROP_SpawnState (S_ARTI_SUMMON)
PROP_Inventory_RespawnTics (30+4200)

View file

@ -40,7 +40,7 @@ FState AArtiTeleportOther::States[] =
};
IMPLEMENT_ACTOR (AArtiTeleportOther, Hexen, 10040, 17)
PROP_Flags (MF_SPECIAL)
PROP_Flags (MF_SPECIAL|MF_COUNTITEM)
PROP_Flags2 (MF2_FLOATBOB)
PROP_SpawnState (S_ARTI_TELOTHER1)
PROP_Inventory_DefMaxAmount

View file

@ -81,7 +81,7 @@ DBaseDecal::DBaseDecal (int statnum, fixed_t z)
DBaseDecal::DBaseDecal (const AActor *basis)
: DThinker(STAT_DECAL),
WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->z), ScaleX(basis->xscale<<10), ScaleY(basis->yscale<<10),
WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->z), ScaleX(basis->scaleX), ScaleY(basis->scaleY),
Alpha(basis->alpha), AlphaColor(basis->alphacolor), Translation(basis->Translation), PicNum(basis->picnum),
RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle)
{

View file

@ -60,8 +60,8 @@ IMPLEMENT_ACTOR(AMapMarker, Any, 9040, 0)
PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY)
PROP_RenderFlags (RF_INVISIBLE)
PROP_SpawnState (0)
PROP_XScale (31)
PROP_YScale (31)
PROP_XScale (FRACUNIT/2)
PROP_YScale (FRACUNIT/2)
END_DEFAULTS
void AMapMarker::BeginPlay ()

View file

@ -193,8 +193,8 @@ static void ApplyActorDefault (int defnum, const char *datastr, int dataint)
}
break;
case ADEF_XScale: actor->xscale = dataint; break;
case ADEF_YScale: actor->yscale = dataint; break;
case ADEF_XScale: actor->scaleX = dataint; break;
case ADEF_YScale: actor->scaleY = dataint; break;
case ADEF_SpawnHealth: actor->health = dataint; break;
case ADEF_ReactionTime: actor->reactiontime = dataint; break;
case ADEF_PainChance: actor->PainChance = dataint; break;

View file

@ -219,8 +219,8 @@ public:
#define PROP_PlayerPawn_ScoreIcon(x) ADD_STRING_PROP(ADEF_PlayerPawn_ScoreIcon,"\27",x)
#define PROP_PlayerPawn_MorphWeapon(x) ADD_STRING_PROP(ADEF_PlayerPawn_MorphWeapon,"\30",x)
#define PROP_XScale(x) ADD_BYTE_PROP(ADEF_XScale,x)
#define PROP_YScale(x) ADD_BYTE_PROP(ADEF_YScale,x)
#define PROP_XScale(x) ADD_LONG_PROP(ADEF_XScale,x)
#define PROP_YScale(x) ADD_LONG_PROP(ADEF_YScale,x)
#define PROP_SpawnHealth(x) ADD_WORD_PROP(ADEF_SpawnHealth,x)
#define PROP_SpawnHealthLong(x) ADD_LONG_PROP(ADEF_SpawnHealth,x)
#define PROP_ReactionTime(x) ADD_BYTE_PROP(ADEF_ReactionTime,x)

View file

@ -1648,7 +1648,8 @@ static void M_DrawClassMenu ()
M_DrawFrame (x, y, 72*CleanXfac, 80*CleanYfac-1);
spriteframe_t *sprframe = &SpriteFrames[sprites[PlayerState->sprite.index].spriteframes + PlayerState->GetFrame()];
int scale = GetDefaultByType (PlayerClass->Type)->xscale + 1;
fixed_t scaleX = GetDefaultByType (PlayerClass->Type)->scaleX;
fixed_t scaleY = GetDefaultByType (PlayerClass->Type)->scaleY;
if (sprframe != NULL)
{
@ -1657,8 +1658,8 @@ static void M_DrawClassMenu ()
{
screen->DrawTexture (tex,
x + 36*CleanXfac, y + 71*CleanYfac,
DTA_DestWidth, MulScale6 (tex->GetWidth() * CleanXfac, scale),
DTA_DestHeight, MulScale6 (tex->GetHeight() * CleanYfac, scale),
DTA_DestWidth, MulScale16 (tex->GetWidth() * CleanXfac, scaleX),
DTA_DestHeight, MulScale16 (tex->GetHeight() * CleanYfac, scaleY),
TAG_DONE);
}
}
@ -2120,19 +2121,19 @@ static void M_PlayerSetupDrawer ()
}
{
spriteframe_t *sprframe;
int scale;
fixed_t Scale;
if (GetDefaultByType (PlayerClass->Type)->flags4 & MF4_NOSKIN ||
players[consoleplayer].userinfo.PlayerClass == -1 ||
PlayerState->sprite.index != GetDefaultByType (PlayerClass->Type)->SpawnState->sprite.index)
{
sprframe = &SpriteFrames[sprites[PlayerState->sprite.index].spriteframes + PlayerState->GetFrame()];
scale = GetDefaultByType (PlayerClass->Type)->xscale + 1;
Scale = GetDefaultByType (PlayerClass->Type)->scaleX;
}
else
{
sprframe = &SpriteFrames[sprites[skins[PlayerSkin].sprite].spriteframes + PlayerState->GetFrame()];
scale = skins[PlayerSkin].scale + 1;
Scale = skins[PlayerSkin].Scale;
}
if (sprframe != NULL)
@ -2147,8 +2148,8 @@ static void M_PlayerSetupDrawer ()
screen->DrawTexture (tex,
(320 - 52 - 32 + xo - 160)*CleanXfac + (SCREENWIDTH)/2,
(PSetupDef.y + LINEHEIGHT*3 + 57 - 104)*CleanYfac + (SCREENHEIGHT/2),
DTA_DestWidth, MulScale6 (tex->GetWidth() * CleanXfac, scale),
DTA_DestHeight, MulScale6 (tex->GetHeight() * CleanYfac, scale),
DTA_DestWidth, MulScale16 (tex->GetWidth() * CleanXfac, Scale),
DTA_DestHeight, MulScale16 (tex->GetHeight() * CleanYfac, Scale),
DTA_Translation, translationtables[TRANSLATION_Players] + 256 * MAXPLAYERS,
TAG_DONE);
}

View file

@ -785,8 +785,8 @@ void ACustomSprite::BeginPlay ()
{
Super::BeginPlay ();
picnum = args[0] + args[1]*256;
xscale = args[2] - 1;
yscale = args[3] - 1;
scaleX = args[2] * (FRACUNIT/64);
scaleY = args[3] * (FRACUNIT/64);
if (args[4] & 2)
{

View file

@ -194,8 +194,8 @@ void AActor::Serialize (FArchive &arc)
<< z
<< angle
<< frame
<< xscale
<< yscale
<< scaleX
<< scaleY
<< RenderStyle
<< renderflags;
if (arc.IsStoring ())
@ -388,7 +388,7 @@ void AActor::Serialize (FArchive &arc)
GetDefaultByType (player->cls)->SpawnState->sprite.index)
{ // Give player back the skin
sprite = skins[player->userinfo.skin].sprite;
xscale = yscale = skins[player->userinfo.skin].scale;
scaleX = scaleY = skins[player->userinfo.skin].Scale;
}
if (Speed == 0)
{
@ -3039,8 +3039,8 @@ FState AActor::States[] =
};
BEGIN_DEFAULTS (AActor, Any, -1, 0)
PROP_XScale (63)
PROP_YScale (63)
PROP_XScale (FRACUNIT)
PROP_YScale (FRACUNIT)
PROP_SpawnState (2)
PROP_SpawnHealth (1000)
PROP_ReactionTime (8)
@ -3470,7 +3470,7 @@ void P_SpawnPlayer (mapthing2_t *mthing, bool tempplayer)
// [RH] Set player sprite based on skin
mobj->sprite = skins[p->userinfo.skin].sprite;
mobj->xscale = mobj->yscale = skins[p->userinfo.skin].scale;
mobj->scaleX = mobj->scaleY = skins[p->userinfo.skin].Scale;
p->DesiredFOV = p->FOV = 90.f;
p->camera = p->mo;

View file

@ -1211,11 +1211,11 @@ void P_CheckPlayerSprites()
if (playeringame[i] && mo != NULL)
{
int crouchspriteno;
int defyscale = mo->GetDefault()->yscale;
fixed_t defscaleY = mo->GetDefault()->scaleY;
if (player->userinfo.skin != 0)
{
defyscale = skins[player->userinfo.skin].scale;
defscaleY = skins[player->userinfo.skin].Scale;
}
// Set the crouch sprite
@ -1240,11 +1240,11 @@ void P_CheckPlayerSprites()
if (crouchspriteno > 0)
{
mo->sprite = crouchspriteno;
mo->yscale = defyscale;
mo->scaleY = defscaleY;
}
else if (player->playerstate != PST_DEAD)
{
mo->yscale = player->crouchfactor < FRACUNIT*3/4 ? defyscale/2 : defyscale;
mo->scaleY = player->crouchfactor < FRACUNIT*3/4 ? defscaleY/2 : defscaleY;
}
}
else // Set the normal sprite
@ -1257,7 +1257,7 @@ void P_CheckPlayerSprites()
{
mo->sprite = skins[player->userinfo.skin].sprite;
}
mo->yscale = defyscale;
mo->scaleY = defscaleY;
}
}
}

View file

@ -855,8 +855,8 @@ public:
BYTE gender; // This skin's gender (not really used)
BYTE range0start;
BYTE range0end;
BYTE scale;
bool othergame; // [GRB]
fixed_t Scale;
int sprite;
int crouchsprite;
int namespc; // namespace for this skin

View file

@ -502,7 +502,7 @@ void R_InitSkins (void)
}
else if (0 == stricmp (key, "scale"))
{
skins[i].scale = clamp ((int)(atof (sc_String) * 64), 1, 256) - 1;
skins[i].Scale = clamp<fixed_t> (FLOAT2FIXED(atof (sc_String)), 1, 256*FRACUNIT);
}
else if (0 == stricmp (key, "game"))
{
@ -871,7 +871,7 @@ void R_InitSprites ()
const PClass *type = PlayerClasses[0].Type;
skins[i].range0start = type->Meta.GetMetaInt (APMETA_ColorRange) & 255;
skins[i].range0end = type->Meta.GetMetaInt (APMETA_ColorRange) >> 8;
skins[i].scale = GetDefaultByType (type)->xscale;
skins[i].Scale = GetDefaultByType (type)->scaleX;
}
R_InitSpriteDefs ();
@ -890,7 +890,7 @@ void R_InitSprites ()
skins[i].face[2] = 'F';
skins[i].range0start = basetype->Meta.GetMetaInt (APMETA_ColorRange) & 255;
skins[i].range0end = basetype->Meta.GetMetaInt (APMETA_ColorRange) >> 8;
skins[i].scale = GetDefaultByType (basetype)->xscale;
skins[i].Scale = GetDefaultByType (basetype)->scaleX;
skins[i].sprite = GetDefaultByType (basetype)->SpawnState->sprite.index;
skins[i].namespc = ns_global;
@ -1297,8 +1297,8 @@ void R_ProjectSprite (AActor *thing, int fakeside)
}
// [RH] Added scaling
gzt = fz + (tex->TopOffset << (FRACBITS-6-3)) * (thing->yscale+1) * tex->ScaleX;
gzb = fz + ((tex->TopOffset - tex->GetHeight()) << (FRACBITS-6-3)) * (thing->yscale+1) * tex->ScaleY;
gzt = fz + MulScale3(thing->scaleY, tex->TopOffset * tex->ScaleX);
gzb = fz + MulScale3(thing->scaleY, (tex->TopOffset - tex->GetHeight()) * tex->ScaleY);
// [RH] Reject sprites that are off the top or bottom of the screen
if (MulScale12 (globaluclip, tz) > viewz - gzb ||
@ -1314,7 +1314,7 @@ void R_ProjectSprite (AActor *thing, int fakeside)
}
// calculate edges of the shape
const fixed_t thingxscalemul = ((thing->xscale+1) * tex->ScaleX) << (16-6-3);
const fixed_t thingxscalemul = MulScale3(thing->scaleX, tex->ScaleX);
tx -= (flip ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul;
x1 = centerx + MulScale32 (tx, xscale);
@ -1330,7 +1330,7 @@ void R_ProjectSprite (AActor *thing, int fakeside)
if (x2 < WindowLeft || x2 <= x1)
return;
xscale = MulScale9 (thing->xscale+1, xscale * tex->ScaleX);
xscale = MulScale19 (thing->scaleX, xscale * tex->ScaleX);
iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1);
x2--;
@ -1377,16 +1377,16 @@ void R_ProjectSprite (AActor *thing, int fakeside)
vis->RenderStyle = thing->RenderStyle;
vis->AlphaColor = thing->alphacolor;
vis->xscale = xscale;
vis->yscale = Scale (InvZtoScale, ((thing->yscale+1) * tex->ScaleY) << (6-3), tz);
vis->yscale = Scale (InvZtoScale, MulScale3(thing->scaleY, tex->ScaleY), tz)>>4;
vis->idepth = (DWORD)DivScale32 (1, tz) >> 1; // tz is 20.12, so idepth ought to be 12.20, but
vis->cx = tx2; // signed math makes it 13.19
vis->gx = fx;
vis->gy = fy;
vis->gz = gzb; // [RH] use gzb, not thing->z
vis->gzt = gzt; // killough 3/27/98
vis->floorclip = SafeDivScale9 (thing->floorclip, (thing->yscale+1) * tex->ScaleY);
vis->texturemid = (tex->TopOffset << FRACBITS)
- SafeDivScale9 (viewz-fz+thing->floorclip, (thing->yscale+1) * tex->ScaleY);
vis->floorclip = FixedDiv (thing->floorclip, MulScale3(thing->scaleY, tex->ScaleY));
vis->texturemid = (tex->TopOffset << FRACBITS) -
FixedDiv (viewz-fz+thing->floorclip, MulScale3(thing->scaleY, tex->ScaleY));
vis->x1 = x1 < WindowLeft ? WindowLeft : x1;
vis->x2 = x2 > WindowRight ? WindowRight : x2;
vis->Translation = thing->Translation; // [RH] thing translation table

View file

@ -1352,7 +1352,7 @@ void InstallStates(FActorInfo *info, AActor *defaults)
static void MakeStateList(const FStateLabels *list, TArray<FStateDefine> &dest)
{
dest.Clear();
for(int i=0;i<list->NumLabels;i++)
if (list != NULL) for(int i=0;i<list->NumLabels;i++)
{
FStateDefine def;
@ -2778,7 +2778,7 @@ static void ActorMass (AActor *defaults, Baggage &bag)
static void ActorXScale (AActor *defaults, Baggage &bag)
{
SC_MustGetFloat();
defaults->xscale=BYTE(sc_Float*64-1);
defaults->scaleY = FLOAT2FIXED(sc_Float);
}
//==========================================================================
@ -2787,7 +2787,7 @@ static void ActorXScale (AActor *defaults, Baggage &bag)
static void ActorYScale (AActor *defaults, Baggage &bag)
{
SC_MustGetFloat();
defaults->yscale=BYTE(sc_Float*64-1);
defaults->scaleY = FLOAT2FIXED(sc_Float);
}
//==========================================================================
@ -2796,7 +2796,7 @@ static void ActorYScale (AActor *defaults, Baggage &bag)
static void ActorScale (AActor *defaults, Baggage &bag)
{
SC_MustGetFloat();
defaults->xscale=defaults->yscale=BYTE(sc_Float*64-1);
defaults->scaleX= defaults->scaleY = FLOAT2FIXED(sc_Float);
}
//==========================================================================

View file

@ -73,6 +73,7 @@ ACTOR ArtiBoostMana : CustomInventory 8003
Game Hexen
SpawnID 26
+FLOATBOB
+COUNTITEM
+INVENTORY.INVBAR
+INVENTORY.PICKUPFLASH
+INVENTORY.FANCYPICKUPSOUND

View file

@ -5,6 +5,7 @@ ACTOR ArtiSpeedBoots : PowerupGiver 8002
Game Hexen
SpawnID 13
+FLOATBOB
+COUNTITEM
+INVENTORY.PICKUPFLASH
Inventory.Icon ARTISPED
Inventory.PickupMessage "$TXT_ARTISPEED"