Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change framerate to 60fps #100

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Mammoth/Include/TSEEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct SEffectMoveCtx
{
CSpaceObject *pObj = NULL; // The object that owns the effect
CVector vOldPos; // Old position of object
Metric rSeconds = -1; // Time since last move

bool bUseOrigin = false; // If TRUE, vOrigin is valid.
CVector vOrigin; // Effect origin
Expand Down Expand Up @@ -404,7 +405,7 @@ class CObjectEffectList

void AccumulateBounds (CSpaceObject *pObj, const CObjectEffectDesc &Desc, int iRotation, RECT *ioBounds);
void Init (const CObjectEffectDesc &Desc, const TArray<IEffectPainter *> &Painters);
void Move (CSpaceObject *pObj, const CVector &vOldPos, bool *retbBoundsChanged = NULL);
void Move (CSpaceObject *pObj, const CVector &vOldPos, Metric rSeconds, bool *retbBoundsChanged = NULL);
void Paint (SViewportPaintCtx &Ctx, const CObjectEffectDesc &Desc, DWORD dwEffects, CG32bitImage &Dest, int x, int y);
void PaintAll (SViewportPaintCtx &Ctx, const CObjectEffectDesc &Desc, CG32bitImage &Dest, int x, int y);
void Update (CSpaceObject *pObj, const CObjectEffectDesc &Desc, int iRotation, DWORD dwEffects);
Expand Down
2 changes: 1 addition & 1 deletion Mammoth/Include/TSEParticleSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class CParticleArray
void ReadFromStream (SLoadCtx &Ctx);
void ResetLastEmit (int iLastDirection, const CVector &vLastEmitPos, const CVector &vLastEmitVel = NullVector);
void SetOrigin (const CVector &vOrigin) { m_vOrigin = vOrigin; }
void UpdateMotionLinear (bool *retbAlive = NULL, CVector *retvAveragePos = NULL);
void UpdateMotionLinear (Metric rSeconds, bool *retbAlive = NULL, CVector *retvAveragePos = NULL);
void UpdateRingCohesion (Metric rRadius, Metric rMinRadius, Metric rMaxRadius, int iCohesion, int iResistance);
void WriteToStream (IWriteStream *pStream) const;

Expand Down
3 changes: 3 additions & 0 deletions Mammoth/Include/TSESystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ struct SSystemUpdateCtx
bool bForcePainted = false; // If TRUE, mark objects as painted
bool bTrackPlayerObjs = false; // If TRUE, make a list of player objects
bool bNoShipEffectUpdate = false; // If TRUE, do not update ship effects
bool bUse60fps = false; // If TRUE, run at 60 fps (two frames per tick)

#ifdef DEBUG_MOVE_PERFORMANCE
int iMoveCalls = 0;
Expand Down Expand Up @@ -591,6 +592,8 @@ class CSystem
void UnnameObject (CSpaceObject &Obj);
void UnregisterEventHandler (CSpaceObject *pObj);
void Update (SSystemUpdateCtx &SystemCtx, SViewportAnnotations *pAnnotations = NULL);
void UpdateBehaviors(SSystemUpdateCtx& SystemCtx, SViewportAnnotations* pAnnotations = NULL);
void UpdatePhysics(SSystemUpdateCtx& SystemCtx, SViewportAnnotations* pAnnotations = NULL, Metric timestep=1.0);
void UpdateExtended (const CTimeSpan &ExtraTime);
void ValidateExclusionRadius (void) const;
void ValidateExclusionRadius (CSpaceObject *pObj, const CStationEncounterDesc::SExclusionDesc &Exclusion) const;
Expand Down
3 changes: 3 additions & 0 deletions Mammoth/Include/TSEUniverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ class CUniverse
void SetHost (IHost *pHost);
void SetPlayer (IPlayerController *pPlayer);
void UpdateTick (SSystemUpdateCtx &Ctx);
void UpdatePhysics (SSystemUpdateCtx& Ctx);
void UpdateMissions (int iTick, CSystem *pSystem);
void UpdateSovereigns (int iTick, CSystem *pSystem);

Expand Down Expand Up @@ -675,6 +676,8 @@ class CUniverse
SViewportAnnotations m_ViewportAnnotations;
EUpdateSpeeds m_iLastUpdateSpeed = updateNone;
DWORD m_dwFrame = 0;
int m_iFrame = 0; // Counter for interpolated physics frames
Metric rFrameStep = 1.0; // Current framestep for interpolated physics frames

// Cached singletons

Expand Down
2 changes: 2 additions & 0 deletions Mammoth/Include/TSUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ struct SHIOptions
m_bForceNonExclusiveMode(false),
m_bForceScreenSize(false),
m_bNoGPUAcceleration(false),
m_bUse60fps(false),
m_iSoundVolume(DEFAULT_SOUND_VOLUME),
m_bDebugVideo(false)
{ }
Expand All @@ -707,6 +708,7 @@ struct SHIOptions
bool m_bForceNonExclusiveMode;
bool m_bForceScreenSize;
bool m_bNoGPUAcceleration;
bool m_bUse60fps; // If TRUE, run at 60 fps

// Sound options
int m_iSoundVolume;
Expand Down
1 change: 1 addition & 0 deletions Mammoth/TSE/CAreaDamage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void CAreaDamage::OnMove (SUpdateCtx &Ctx, const CVector &vOldPos, Metric rSecon
{
SEffectMoveCtx Ctx;
Ctx.pObj = this;
Ctx.rSeconds = rSeconds;
bool bBoundsChanged;

m_pPainter->OnMove(Ctx, &bBoundsChanged);
Expand Down
61 changes: 31 additions & 30 deletions Mammoth/TSE/CBeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,37 @@ void CBeam::OnMove (SUpdateCtx &Ctx, const CVector &vOldPos, Metric rSeconds)

if (m_pHit == NULL)
m_vPaintTo = GetPos();

// See if the beam hit anything

if (m_pHit)
{
// Old-style bonus

TSharedPtr<CItemEnhancementStack> pEnhancements(new CItemEnhancementStack);
pEnhancements->InsertHPBonus(NULL, m_iBonus);

// Tell the object hit that it has been damaged

SDamageCtx DamageCtx(m_pHit,
*m_pDesc,
pEnhancements,
m_Source,
this,
GetAge(),
AngleMod(m_iHitDir + mathRandom(0, 30) - 15),
m_vPaintTo);

EDamageResults result = m_pHit->Damage(DamageCtx);

// Set the beam to destroy itself after a hit

if (m_pDesc->GetPassthrough() == 0
|| result == damageNoDamage
|| result == damageAbsorbedByShields
|| mathRandom(1, 100) > m_pDesc->GetPassthrough())
Destroy(removedFromSystem, CDamageSource());
}
}

void CBeam::ObjectDestroyedHook (const SDestroyCtx &Ctx)
Expand Down Expand Up @@ -232,36 +263,6 @@ void CBeam::OnUpdate (SUpdateCtx &Ctx, Metric rSecondsPerTick)

m_iTick++;

// See if the beam hit anything

if (m_pHit)
{
// Old-style bonus

TSharedPtr<CItemEnhancementStack> pEnhancements(new CItemEnhancementStack);
pEnhancements->InsertHPBonus(NULL, m_iBonus);

// Tell the object hit that it has been damaged

SDamageCtx DamageCtx(m_pHit,
*m_pDesc,
pEnhancements,
m_Source,
this,
GetAge(),
AngleMod(m_iHitDir + mathRandom(0, 30) - 15),
m_vPaintTo);

EDamageResults result = m_pHit->Damage(DamageCtx);

// Set the beam to destroy itself after a hit

if (m_pDesc->GetPassthrough() == 0
|| result == damageNoDamage
|| result == damageAbsorbedByShields
|| mathRandom(1, 100) > m_pDesc->GetPassthrough())
bDestroy = true;
}

// See if the beam has faded out

Expand Down
28 changes: 11 additions & 17 deletions Mammoth/TSE/CContinuousBeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,14 @@ void CContinuousBeam::OnMove (SUpdateCtx &Ctx, const CVector &vOldPos, Metric rS
// Handle moving

{
int i;
// Update the effect painter

if (m_pPainter)
{
SEffectMoveCtx Ctx;
Ctx.pObj = this;
Ctx.rSeconds = rSeconds;

m_pPainter->OnMove(Ctx);
}
Expand All @@ -500,6 +502,15 @@ void CContinuousBeam::OnMove (SUpdateCtx &Ctx, const CVector &vOldPos, Metric rS

SetPos(vNewPos);
SetBounds(rMaxBoundsX, rMaxBoundsY);

// Do damage

for (i = 0; i < m_Hits.GetCount(); i++)
{
const CHitCtx& Hit = m_Hits[i];

EDamageResults iResult = DoDamage(Hit.GetHitObj(), Hit.GetHitPos(), Hit.GetHitDir());
}
}

void CContinuousBeam::ObjectDestroyedHook (const SDestroyCtx &Ctx)
Expand Down Expand Up @@ -698,23 +709,6 @@ void CContinuousBeam::OnUpdate (SUpdateCtx &Ctx, Metric rSecondsPerTick)
m_pPainter->OnUpdate(UpdateCtx);
}

// Do damage

for (i = 0; i < m_Hits.GetCount(); i++)
{
const CHitCtx &Hit = m_Hits[i];

// Do damage

EDamageResults iResult = DoDamage(Hit.GetHitObj(), Hit.GetHitPos(), Hit.GetHitDir());

// NOTE: No need to do anything with the result because we've already
// determined whether the beam/segment needs to be split. We do not
// check for passthrough here because we already checked in OnMove.
// [And we have to check in OnMove because otherwise we would not
// paint correctly.]
}

// Update each segment (except for the pseudo segment).

bool bAlive = false;
Expand Down
1 change: 1 addition & 0 deletions Mammoth/TSE/CEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ void CEffect::OnMove (SUpdateCtx &Ctx, const CVector &vOldPos, Metric rSeconds)
{
SEffectMoveCtx Ctx;
Ctx.pObj = this;
Ctx.rSeconds = rSeconds;

// Tell the painter about the new absolute position

Expand Down
106 changes: 56 additions & 50 deletions Mammoth/TSE/CMissile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ void CMissile::OnMove (SUpdateCtx &Ctx, const CVector &vOldPos, Metric rSeconds)
SEffectMoveCtx Ctx;
Ctx.pObj = this;
Ctx.vOldPos = vOldPos;
Ctx.rSeconds = rSeconds;

bool bBoundsChanged;
m_pPainter->OnMove(Ctx, &bBoundsChanged);
Expand Down Expand Up @@ -916,6 +917,61 @@ void CMissile::OnMove (SUpdateCtx &Ctx, const CVector &vOldPos, Metric rSeconds)
else
m_fPassthrough = false;

// If we hit something, then process damage now

if (m_pHit)
{
bool bDestroy = false;

// If we have fragments, then explode now

if (m_pDesc->ProximityBlast()
&& m_iTick >= m_pDesc->GetProximityFailsafe())
{
CreateFragments(m_vHitPos);
bDestroy = true;
}

// Otherwise, if this was a direct hit, then we do damage

else if (m_iHitDir != -1)
{
SDamageCtx DamageCtx(m_pHit,
*m_pDesc,
m_pEnhancements,
m_Source,
this,
GetAge(),
AngleMod(m_iHitDir + mathRandom(0, 30) - 15),
m_vHitPos);

EDamageResults result = m_pHit->Damage(DamageCtx);

// If we hit another missile (or some small object) there is a chance
// that we continue

if (result == damagePassthrough || result == damagePassthroughDestroyed)
{
m_iHitPoints = m_iHitPoints / 2;
bDestroy = (m_iHitPoints == 0);
}

// If we have passthrough and we did not reflect, then we
// continue without being destroyed.

else if (m_fPassthrough && !DamageCtx.IsShotReflected())
{
}

// Otherwise, missile is destroyed on hit

else
bDestroy = true;
}

if (bDestroy && !SetMissileFade())
Destroy(removedFromSystem, CDamageSource());
}
DEBUG_CATCH
}

Expand Down Expand Up @@ -1408,56 +1464,6 @@ void CMissile::OnUpdate (SUpdateCtx &Ctx, Metric rSecondsPerTick)
bDestroy = true;
}

// If we hit something, then do damage

else if (m_pHit)
{
// If we have fragments, then explode now

if (m_pDesc->ProximityBlast()
&& m_iTick >= m_pDesc->GetProximityFailsafe())
{
CreateFragments(m_vHitPos);
bDestroy = true;
}

// Otherwise, if this was a direct hit, then we do damage

else if (m_iHitDir != -1)
{
SDamageCtx DamageCtx(m_pHit,
*m_pDesc,
m_pEnhancements,
m_Source,
this,
GetAge(),
AngleMod(m_iHitDir + mathRandom(0, 30) - 15),
m_vHitPos);

EDamageResults result = m_pHit->Damage(DamageCtx);

// If we hit another missile (or some small object) there is a chance
// that we continue

if (result == damagePassthrough || result == damagePassthroughDestroyed)
{
m_iHitPoints = m_iHitPoints / 2;
bDestroy = (m_iHitPoints == 0);
}

// If we have passthrough and we did not reflect, then we
// continue without being destroyed.

else if (m_fPassthrough && !DamageCtx.IsShotReflected())
{ }

// Otherwise, missile is destroyed on hit

else
bDestroy = true;
}
}

// See if the missile has faded out

if (bDestroy || --m_iLifeLeft <= 0)
Expand Down
3 changes: 2 additions & 1 deletion Mammoth/TSE/CObjectEffectList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void CObjectEffectList::Init (const CObjectEffectDesc &Desc, const TArray<IEffec
m_FixedEffects[i].pPainter = Painters[i];
}

void CObjectEffectList::Move (CSpaceObject *pObj, const CVector &vOldPos, bool *retbBoundsChanged)
void CObjectEffectList::Move (CSpaceObject *pObj, const CVector &vOldPos, Metric rSeconds, bool *retbBoundsChanged)

// Move
//
Expand All @@ -95,6 +95,7 @@ void CObjectEffectList::Move (CSpaceObject *pObj, const CVector &vOldPos, bool *
SEffectMoveCtx MoveCtx;
MoveCtx.pObj = pObj;
MoveCtx.vOldPos = vOldPos;
MoveCtx.rSeconds = rSeconds;

for (i = 0; i < m_FixedEffects.GetCount(); i++)
if (m_FixedEffects[i].pPainter)
Expand Down
1 change: 1 addition & 0 deletions Mammoth/TSE/COverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,7 @@ void COverlay::Update (CSpaceObject *pSource, int iScale, int iRotation, bool *r

SEffectMoveCtx MoveCtx;
MoveCtx.pObj = pSource;
MoveCtx.rSeconds = g_SecondsPerUpdate; // FIXME - this is behavior update, but calling OnMove below

// If our painter needs an origin, then compute it and set it.

Expand Down
Loading