mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
- added a distancecheck property to AActor that allows a given CVAR to be used as maximum display distance for actors of this type.
This is for WolfenDoom: BOA, which has some scripted sprite distance checks that very negatively affected performance.
This commit is contained in:
parent
e1a683b9ec
commit
3f0ed5d252
4 changed files with 43 additions and 2 deletions
|
@ -804,6 +804,12 @@ public:
|
||||||
return bloodcls;
|
return bloodcls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Distance2DSquared(AActor *other, bool absolute = false)
|
||||||
|
{
|
||||||
|
DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||||
|
return (Pos().XY() - otherpos).LengthSquared();
|
||||||
|
}
|
||||||
|
|
||||||
double Distance2D(AActor *other, bool absolute = false)
|
double Distance2D(AActor *other, bool absolute = false)
|
||||||
{
|
{
|
||||||
DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||||
|
|
|
@ -53,6 +53,7 @@ struct Baggage;
|
||||||
class FScanner;
|
class FScanner;
|
||||||
struct FActorInfo;
|
struct FActorInfo;
|
||||||
class FArchive;
|
class FArchive;
|
||||||
|
class FIntCVar;
|
||||||
|
|
||||||
// Sprites that are fixed in position because they can have special meanings.
|
// Sprites that are fixed in position because they can have special meanings.
|
||||||
enum
|
enum
|
||||||
|
@ -259,6 +260,7 @@ public:
|
||||||
|
|
||||||
DDropItem *DropItems;
|
DDropItem *DropItems;
|
||||||
FString SourceLumpName;
|
FString SourceLumpName;
|
||||||
|
FIntCVar *distancecheck;
|
||||||
|
|
||||||
// Old Decorate compatibility stuff
|
// Old Decorate compatibility stuff
|
||||||
bool DontHurtShooter;
|
bool DontHurtShooter;
|
||||||
|
|
|
@ -1246,9 +1246,20 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside)
|
||||||
// Handle all things in sector.
|
// Handle all things in sector.
|
||||||
for (thing = sec->thinglist; thing; thing = thing->snext)
|
for (thing = sec->thinglist; thing; thing = thing->snext)
|
||||||
{
|
{
|
||||||
|
FIntCVar *cvar = thing->GetClass()->distancecheck;
|
||||||
|
if (cvar != NULL && *cvar >= 0)
|
||||||
|
{
|
||||||
|
double dist = thing->Distance2DSquared(camera);
|
||||||
|
double check = (double)**cvar;
|
||||||
|
if (dist >= check * check)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// find fake level
|
// find fake level
|
||||||
for(int i = 0; i < (int)frontsector->e->XFloor.ffloors.Size(); i++) {
|
for(auto rover : frontsector->e->XFloor.ffloors)
|
||||||
rover = frontsector->e->XFloor.ffloors[i];
|
{
|
||||||
if(!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue;
|
if(!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) continue;
|
||||||
if(!(rover->flags & FF_SOLID) || rover->alpha != 255) continue;
|
if(!(rover->flags & FF_SOLID) || rover->alpha != 255) continue;
|
||||||
if(!fakefloor)
|
if(!fakefloor)
|
||||||
|
|
|
@ -1523,6 +1523,28 @@ DEFINE_PROPERTY(riplevelmax, I, Actor)
|
||||||
defaults->RipLevelMax = id;
|
defaults->RipLevelMax = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
DEFINE_PROPERTY(distancecheck, S, Actor)
|
||||||
|
{
|
||||||
|
PROP_STRING_PARM(cvar, 0);
|
||||||
|
FBaseCVar *scratch;
|
||||||
|
FBaseCVar *cv = FindCVar(cvar, &scratch);
|
||||||
|
if (cv == NULL)
|
||||||
|
{
|
||||||
|
I_Error("CVar %s not defined", cvar);
|
||||||
|
}
|
||||||
|
else if (cv->GetRealType() == CVAR_Int)
|
||||||
|
{
|
||||||
|
static_cast<PClassActor*>(info)->distancecheck = static_cast<FIntCVar *>(cv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
I_Error("CVar %s must of type Int", cvar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Special inventory properties
|
// Special inventory properties
|
||||||
|
|
Loading…
Reference in a new issue