This commit is contained in:
raa-eruanna 2016-09-24 23:36:47 -04:00
commit 9ecb7d44f7
16 changed files with 195 additions and 17 deletions

View file

@ -48,12 +48,14 @@ function( add_pk3 PK3_NAME PK3_DIR )
COMMAND zipdir -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR}
DEPENDS zipdir )
endif()
# Touch the zipdir executable here so that the pk3s are forced to
# rebuild each time since their dependecy has "changed."
add_custom_target( ${PK3_TARGET} ALL
COMMAND ${CMAKE_COMMAND} -E touch $<TARGET_FILE:zipdir>
DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} )
# Grab a list of top-level PK3 folder files, so we can conveniently see them in the IDE
file(GLOB PK3_SRCS ${PK3_DIR}/*)
# Touch the zipdir executable here so that the pk3s are forced to
# rebuild each time since their dependecy has "changed."
add_custom_target( ${PK3_TARGET} ALL
COMMAND ${CMAKE_COMMAND} -E touch $<TARGET_FILE:zipdir>
DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME}
SOURCES "${PK3_SRCS}")
endfunction()
# Macro for building libraries without debugging information

View file

@ -417,7 +417,10 @@ enum ActorRenderFlag
RF_INVISIBLE = 0x8000, // Don't bother drawing this actor
RF_ROLLSPRITE = 0x40000, //[marrub]roll the sprite billboard
RF_DONTFLIP = 0x80000, // Don't flip it when viewed from behind.
RF_ROLLCENTER = 0x100000, // Rotate from the center of sprite instead of offsets
RF_ROLLCENTER = 0x00100000, // Rotate from the center of sprite instead of offsets
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_FORCEYBILLBOARD = 0x10000, // [BB] OpenGL only: draw with y axis billboard, i.e. anchored to the floor (overrides gl_billboard_mode setting)
RF_FORCEXYBILLBOARD = 0x20000, // [BB] OpenGL only: draw with xy axis billboard, i.e. unanchored (overrides gl_billboard_mode setting)
@ -959,6 +962,7 @@ public:
inline void SetFriendPlayer(player_t *player);
bool IsVisibleToPlayer() const;
bool IsInsideVisibleAngles() const;
// Calculate amount of missile damage
virtual int GetMissileDamage(int mask, int add);
@ -984,6 +988,10 @@ public:
DAngle SpriteAngle;
DAngle SpriteRotation;
DAngle VisibleStartAngle;
DAngle VisibleStartPitch;
DAngle VisibleEndAngle;
DAngle VisibleEndPitch;
DRotator Angles;
DVector3 Vel;
double Speed;

View file

@ -1884,7 +1884,7 @@ void G_DoLoadGame ()
}
else
{
Printf("Savegame is from another ZDoom-based engine: %s\n", engine);
Printf("Savegame is from another ZDoom-based engine: %s\n", engine.GetChars());
}
delete resfile;
return;
@ -2261,7 +2261,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio
}
auto picdata = savepic.GetBuffer();
FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, crc32(0, &(*picdata)[0], picdata->Size()), (char*)&(*picdata)[0] };
FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, static_cast<unsigned int>(crc32(0, &(*picdata)[0], picdata->Size())), (char*)&(*picdata)[0] };
savegame_content.Push(bufpng);
savegame_filenames.Push("savepic.png");

View file

@ -163,7 +163,7 @@ void ADynamicLight::Serialize(FSerializer &arc)
("lighttype", lighttype, def->lighttype)
("tickcount", m_tickCount, def->m_tickCount)
("currentradius", m_currentRadius, def->m_currentRadius)
.Array("radius", m_Radius, def->m_Radius, 2);
.Array("lightradius", m_Radius, def->m_Radius, 2);
if (lighttype == PulseLight)
arc("lastupdate", m_lastUpdate, def->m_lastUpdate)

View file

@ -636,7 +636,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
sector_t * rendersector;
// Don't waste time projecting sprites that are definitely not visible.
if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer())
if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer() || !thing->IsInsideVisibleAngles())
{
return;
}

View file

@ -336,6 +336,10 @@ xx(ReactionTime)
xx(MeleeRange)
xx(Speed)
xx(Clamp)
xx(VisibleStartAngle)
xx(VisibleStartPitch)
xx(VisibleEndAngle)
xx(VisibleEndPitch)
// Various actor names which are used internally
xx(MapSpot)

View file

@ -306,7 +306,11 @@ void AActor::Serialize(FSerializer &arc)
A("spriteangle", SpriteAngle)
A("spriterotation", SpriteRotation)
("alternative", alternative)
A("tag", Tag);
A("tag", Tag)
A("visiblestartangle",VisibleStartAngle)
A("visibleendangle",VisibleEndAngle)
A("visiblestartpitch",VisibleStartPitch)
A("visibleendpitch",VisibleEndPitch);
}
#undef A
@ -1019,6 +1023,69 @@ bool AActor::CheckLocalView (int playernum) const
return false;
}
//============================================================================
//
// AActor :: IsInsideVisibleAngles
//
// Returns true if this actor is within viewing angle/pitch visibility.
//
//============================================================================
bool AActor::IsInsideVisibleAngles() const
{
// Don't bother masking if not wanted.
if (!(renderflags & RF_MASKROTATION))
return true;
if (players[consoleplayer].camera == nullptr)
return true;
DAngle anglestart = VisibleStartAngle.Normalized180();
DAngle angleend = VisibleEndAngle.Normalized180();
DAngle pitchstart = VisibleStartPitch.Normalized180();
DAngle pitchend = VisibleEndPitch.Normalized180();
if (anglestart > angleend)
{
DAngle temp = anglestart;
anglestart = angleend;
angleend = temp;
}
if (pitchstart > angleend)
{
DAngle temp = pitchstart;
pitchstart = pitchend;
pitchend = temp;
}
player_t* pPlayer = players[consoleplayer].camera->player;
if (pPlayer && pPlayer->mo)
{
AActor *mo = pPlayer->mo;
DVector3 diffang = Vec3To(mo);
DAngle to = diffang.Angle();
if (!(renderflags & RF_ABSMASKANGLE))
to = deltaangle(Angles.Yaw, to);
// Note that this check is inversed due to only being able to vectorize
// from one way (this actor to the player). It still means to pass
// if the player is within the visible angles.
if ((to <= anglestart || to >= angleend))
{
to = diffang.Pitch();
if (!(renderflags & RF_ABSMASKPITCH))
to = deltaangle(Angles.Pitch, to);
return !!(to >= pitchstart && to <= pitchend);
}
else return false;
}
return true;
}
//============================================================================
//
// AActor :: IsVisibleToPlayer

View file

@ -761,7 +761,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
if (thing == NULL ||
(thing->renderflags & RF_INVISIBLE) ||
!thing->RenderStyle.IsVisible(thing->Alpha) ||
!thing->IsVisibleToPlayer())
!thing->IsVisibleToPlayer() ||
!thing->IsInsideVisibleAngles())
{
return;
}

View file

@ -859,7 +859,7 @@ void FSerializer::ReadObjects(bool hubtravel)
PClass *cls = PClass::FindClass(clsname);
if (cls == nullptr)
{
Printf("Unknown object class '%d' in savegame", clsname.GetChars());
Printf("Unknown object class '%s' in savegame", clsname.GetChars());
founderrors = true;
r->mDObjects[i] = RUNTIME_CLASS(AActor)->CreateNew(); // make sure we got at least a valid pointer for the duration of the loading process.
r->mDObjects[i]->Destroy(); // but we do not want to keep this around, so destroy it right away.

View file

@ -163,7 +163,7 @@ public:
template<class T>
FSerializer &Enum(const char *key, T &obj)
{
auto val = (std::underlying_type<T>::type)obj;
auto val = (typename std::underlying_type<T>::type)obj;
Serialize(*this, key, val, nullptr);
obj = (T)val;
return *this;
@ -299,4 +299,4 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TFlags<T, TT> &flags,
}
#endif
#endif

View file

@ -7344,3 +7344,55 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpriteRotation)
mobj->SpriteRotation = angle;
ACTION_RETURN_BOOL(true);
}
//==========================================================================
//
// A_SetMaskRotation(anglestart, angleend, pitchstart, pitchend, flags, ptr)
//
// Specifies how much to fake a sprite rotation.
//==========================================================================
enum VRFFlags
{
VRF_NOANGLESTART = 1,
VRF_NOANGLEEND = 1 << 1,
VRF_NOPITCHSTART = 1 << 2,
VRF_NOPITCHEND = 1 << 3,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetVisibleRotation)
{
PARAM_ACTION_PROLOGUE;
PARAM_ANGLE_OPT(anglestart) { anglestart = 0.; }
PARAM_ANGLE_OPT(angleend) { angleend = 0.; }
PARAM_ANGLE_OPT(pitchstart) { pitchstart = 0.; }
PARAM_ANGLE_OPT(pitchend) { pitchend = 0.; }
PARAM_INT_OPT(flags) { flags = 0; }
PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; }
AActor *mobj = COPY_AAPTR(self, ptr);
if (mobj == nullptr)
{
ACTION_RETURN_BOOL(false);
}
if (!(flags & VRF_NOANGLESTART))
{
mobj->VisibleStartAngle = anglestart;
}
if (!(flags & VRF_NOANGLEEND))
{
mobj->VisibleEndAngle = angleend;
}
if (!(flags & VRF_NOPITCHSTART))
{
mobj->VisibleStartPitch = pitchstart;
}
if (!(flags & VRF_NOPITCHEND))
{
mobj->VisibleEndPitch = pitchend;
}
ACTION_RETURN_BOOL(true);
}

View file

@ -275,6 +275,9 @@ static FFlagDef ActorFlagDefs[]=
DEFINE_FLAG(RF, WALLSPRITE, AActor, renderflags),
DEFINE_FLAG(RF, DONTFLIP, AActor, renderflags),
DEFINE_FLAG(RF, ROLLCENTER, AActor, renderflags),
DEFINE_FLAG(RF, MASKROTATION, AActor, renderflags),
DEFINE_FLAG(RF, ABSMASKANGLE, AActor, renderflags),
DEFINE_FLAG(RF, ABSMASKPITCH, AActor, renderflags),
// Bounce flags
DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags),
@ -667,4 +670,8 @@ void InitThingdef()
symt.AddSymbol(new PField(NAME_Threshold, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, threshold)));
symt.AddSymbol(new PField(NAME_DefThreshold, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, DefThreshold)));
symt.AddSymbol(new PField(NAME_Damage, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, DamageVal)));
symt.AddSymbol(new PField(NAME_VisibleStartAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleStartAngle)));
symt.AddSymbol(new PField(NAME_VisibleStartPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleStartPitch)));
symt.AddSymbol(new PField(NAME_VisibleEndAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndAngle)));
symt.AddSymbol(new PField(NAME_VisibleEndPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndPitch)));
}

View file

@ -1431,6 +1431,28 @@ DEFINE_PROPERTY(spriterotation, F, Actor)
defaults->SpriteRotation = i;
}
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(visibleangles, Ff, Actor)
{
PROP_DOUBLE_PARM(visstart, 0);
PROP_DOUBLE_PARM(visend, 0);
defaults->VisibleStartAngle = visstart;
defaults->VisibleEndAngle = visend;
}
//==========================================================================
//
//==========================================================================
DEFINE_PROPERTY(visiblepitch, Ff, Actor)
{
PROP_DOUBLE_PARM(visstart, 0);
PROP_DOUBLE_PARM(visend, 0);
defaults->VisibleStartPitch = visstart;
defaults->VisibleEndPitch = visend;
}
//==========================================================================
//
//==========================================================================

View file

@ -75,7 +75,7 @@ const char *GetVersionString();
#define SAVEGAME_EXT "zds"
// MINSAVEVER is the minimum level snapshot version that can be loaded.
#define MINSAVEVER 4545
#define MINSAVEVER 4550
// Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got.

View file

@ -38,6 +38,8 @@ ACTOR Actor native //: Thinker
SpriteAngle 0
SpriteRotation 0
StencilColor "00 00 00"
VisibleAngles 0, 0
VisiblePitch 0, 0
// Functions
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
@ -340,6 +342,7 @@ ACTOR Actor native //: Thinker
action native bool A_CopySpriteFrame(int from, int to, int flags = 0);
action native bool A_SetSpriteAngle(float angle = 0, int ptr = AAPTR_DEFAULT);
action native bool A_SetSpriteRotation(float angle = 0, int ptr = AAPTR_DEFAULT);
action native bool A_SetVisibleRotation(float anglestart = 0, float angleend = 0, float pitchstart = 0, float pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT);
native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0);
native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0);

View file

@ -677,4 +677,16 @@ enum
{
CPSF_NOSPRITE = 1,
CPSF_NOFRAME = 1 << 1,
};
//Flags for A_SetMaskRotation
enum
{
VRF_NOANGLESTART = 1,
VRF_NOANGLEEND = 1 << 1,
VRF_NOPITCHSTART = 1 << 2,
VRF_NOPITCHEND = 1 << 3,
VRF_NOANGLE = VRF_NOANGLESTART|VRF_NOANGLEEND,
VRF_NOPITCH = VRF_NOPITCHSTART|VRF_NOPITCHEND,
};