Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'thread-pooling' of https://github.com/cortex-command-co…
Browse files Browse the repository at this point in the history
  • Loading branch information
Causeless committed Nov 21, 2023
2 parents 87be473 + 7d91cb4 commit 5aed051
Show file tree
Hide file tree
Showing 71 changed files with 15,315 additions and 175 deletions.
2 changes: 1 addition & 1 deletion Activities/GibEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ void GibEditor::Update()
std::list<MovableObject *> *pEditedGibList = m_pEditorGUI->GetPlacedGibs();
MovableObject *pGibCopy = 0;

for (std::list<Gib>::iterator gItr = pLoadedGibList->begin(); gItr != pLoadedGibList->end(); ++gItr)
for (auto gItr = pLoadedGibList->begin(); gItr != pLoadedGibList->end(); ++gItr)
{
pGibCopy = dynamic_cast<MovableObject *>((*gItr).GetParticlePreset()->Clone());
if (pGibCopy)
Expand Down
4 changes: 4 additions & 0 deletions Entities/ACDropShip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "AEmitter.h"
#include "PresetMan.h"

#include "tracy/Tracy.hpp"

namespace RTE {

ConcreteClassInfo(ACDropShip, ACraft, 10);
Expand Down Expand Up @@ -272,6 +274,8 @@ MOID ACDropShip::DetectObstacle(float distance)

void ACDropShip::PreControllerUpdate()
{
ZoneScoped;

ACraft::PreControllerUpdate();

// TODO: Improve and make optional thrusters more robust!
Expand Down
6 changes: 6 additions & 0 deletions Entities/ACrab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "GUI.h"
#include "AllegroBitmap.h"

#include "tracy/Tracy.hpp"

namespace RTE {

ConcreteClassInfo(ACrab, Actor, 20);
Expand Down Expand Up @@ -997,6 +999,8 @@ void ACrab::OnNewMovePath()

void ACrab::PreControllerUpdate()
{
ZoneScoped;

Actor::PreControllerUpdate();

float deltaTime = g_TimerMan.GetDeltaTimeSecs();
Expand Down Expand Up @@ -1383,6 +1387,8 @@ void ACrab::PreControllerUpdate()

void ACrab::Update()
{
ZoneScoped;

Actor::Update();

////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions Entities/ADoor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "PresetMan.h"
#include "SettingsMan.h"

#include "tracy/Tracy.hpp"

namespace RTE {

ConcreteClassInfo(ADoor, Actor, 20);
Expand Down Expand Up @@ -379,6 +381,8 @@ namespace RTE {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void ADoor::Update() {
ZoneScoped;

if (m_Door) {
if (m_DoorState != STOPPED && m_Status != Actor::Status::INACTIVE && m_SensorTimer.IsPastSimMS(m_SensorInterval)) {
UpdateSensors();
Expand Down
22 changes: 11 additions & 11 deletions Entities/AEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,17 @@ void AEmitter::Update()
m_WasEmitting = false;
}
}

// Set the screen flash effect to draw at the final post processing stage
if (m_EmitEnabled && (!m_FlashOnlyOnBurst || m_BurstTriggered) && m_pFlash && m_pFlash->GetScreenEffect()) {
// Fudge the glow pos forward a bit so it aligns nicely with the flash
Vector emitPos(m_pFlash->GetScreenEffect()->w * 0.3F * m_FlashScale, 0);
emitPos.RadRotate(m_HFlipped ? c_PI + m_Rotation.GetRadAngle() - m_EmitAngle.GetRadAngle() : m_Rotation.GetRadAngle() + m_EmitAngle.GetRadAngle());
emitPos = m_Pos + RotateOffset(m_EmissionOffset) + emitPos;
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(emitPos)) {
g_PostProcessMan.RegisterPostEffect(emitPos, m_pFlash->GetScreenEffect(), m_pFlash->GetScreenEffectHash(), RandomNum(m_pFlash->GetEffectStopStrength(), m_pFlash->GetEffectStartStrength()) * std::clamp(m_FlashScale, 0.0F, 1.0F), m_pFlash->GetEffectRotAngle());
}
}
}


Expand All @@ -616,17 +627,6 @@ void AEmitter::Draw(BITMAP *pTargetBitmap,
if (m_pFlash && m_pFlash->IsDrawnAfterParent() &&
!onlyPhysical && mode == g_DrawColor && m_EmitEnabled && (!m_FlashOnlyOnBurst || m_BurstTriggered))
m_pFlash->Draw(pTargetBitmap, targetPos, mode, onlyPhysical);

// Set the screen flash effect to draw at the final post processing stage
if (m_EmitEnabled && (!m_FlashOnlyOnBurst || m_BurstTriggered) && m_pFlash && m_pFlash->GetScreenEffect() && mode == g_DrawColor && !onlyPhysical) {
// Fudge the glow pos forward a bit so it aligns nicely with the flash
Vector emitPos(m_pFlash->GetScreenEffect()->w * 0.3F * m_FlashScale, 0);
emitPos.RadRotate(m_HFlipped ? c_PI + m_Rotation.GetRadAngle() - m_EmitAngle.GetRadAngle() : m_Rotation.GetRadAngle() + m_EmitAngle.GetRadAngle());
emitPos = m_Pos + RotateOffset(m_EmissionOffset) + emitPos;
if (!g_SceneMan.ObscuredPoint(emitPos)) {
g_PostProcessMan.RegisterPostEffect(emitPos, m_pFlash->GetScreenEffect(), m_pFlash->GetScreenEffectHash(), RandomNum(m_pFlash->GetEffectStopStrength(), m_pFlash->GetEffectStartStrength()) * std::clamp(m_FlashScale, 0.0F, 1.0F), m_pFlash->GetEffectRotAngle());
}
}
}

} // namespace RTE
8 changes: 7 additions & 1 deletion Entities/AHuman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "GUI.h"
#include "AllegroBitmap.h"

#include "tracy/Tracy.hpp"

namespace RTE {

ConcreteClassInfo(AHuman, Actor, 20);
Expand Down Expand Up @@ -1710,6 +1712,8 @@ void AHuman::UpdateWalkAngle(AHuman::Layer whichLayer) {

void AHuman::PreControllerUpdate()
{
ZoneScoped;

Actor::PreControllerUpdate();

float deltaTime = g_TimerMan.GetDeltaTimeSecs();
Expand Down Expand Up @@ -2142,7 +2146,7 @@ void AHuman::PreControllerUpdate()
reach += m_pFGArm ? m_pFGArm->GetMaxLength() : m_pBGArm->GetMaxLength();
reachPoint = m_pFGArm ? m_pFGArm->GetJointPos() : m_pBGArm->GetJointPos();

MOID itemMOID = g_SceneMan.CastMORay(reachPoint, Vector(reach * RandomNum(0.5F, 1.0F) * GetFlipFactor(), 0).RadRotate(m_pItemInReach ? adjustedAimAngle : RandomNum(-(c_HalfPI + c_EighthPI), m_AimAngle * 0.75F + c_EighthPI) * GetFlipFactor()), m_MOID, Activity::NoTeam, g_MaterialGrass, true, 3);
MOID itemMOID = g_SceneMan.CastMORay(reachPoint, Vector(reach * RandomNum(0.5F, 1.0F) * GetFlipFactor(), 0).RadRotate(m_pItemInReach ? adjustedAimAngle : RandomNum(-(c_HalfPI + c_EighthPI), m_AimAngle * 0.75F + c_EighthPI) * GetFlipFactor()), m_MOID, m_Team, g_MaterialGrass, true, 3);

if (MovableObject *foundMO = g_MovableMan.GetMOFromID(itemMOID)) {
if (HeldDevice *foundDevice = dynamic_cast<HeldDevice *>(foundMO->GetRootParent())) {
Expand Down Expand Up @@ -2499,6 +2503,8 @@ void AHuman::PreControllerUpdate()

void AHuman::Update()
{
ZoneScoped;

float rot = m_Rotation.GetRadAngle(); // eugh, for backwards compat to be the same behaviour as with multithreaded AI

Actor::Update();
Expand Down
4 changes: 4 additions & 0 deletions Entities/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "GUI.h"
#include "AllegroBitmap.h"

#include "tracy/Tracy.hpp"

namespace RTE {

ConcreteClassInfo(Actor, MOSRotating, 20);
Expand Down Expand Up @@ -1309,6 +1311,8 @@ void Actor::PreControllerUpdate() {

void Actor::Update()
{
ZoneScoped;

/////////////////////////////////
// Hit Body update and handling
MOSRotating::Update();
Expand Down
16 changes: 8 additions & 8 deletions Entities/HDFirearm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,14 @@ void HDFirearm::Update()
}

m_FiredLastFrame = m_FireFrame;

// Set the screen flash effect to draw at the final post processing stage
if (m_FireFrame && m_pFlash && m_pFlash->GetScreenEffect()) {
Vector muzzlePos = m_Pos + RotateOffset(m_MuzzleOff + Vector(m_pFlash->GetSpriteWidth() * 0.3F, 0));
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(muzzlePos)) {
g_PostProcessMan.RegisterPostEffect(muzzlePos, m_pFlash->GetScreenEffect(), m_pFlash->GetScreenEffectHash(), RandomNum(m_pFlash->GetEffectStopStrength(), m_pFlash->GetEffectStartStrength()), m_pFlash->GetEffectRotAngle());
}
}
}


Expand Down Expand Up @@ -1144,14 +1152,6 @@ void HDFirearm::Draw(BITMAP *pTargetBitmap, const Vector &targetPos, DrawMode mo
if (m_pFlash && m_FireFrame && m_pFlash->IsDrawnAfterParent() && mode == g_DrawColor && !onlyPhysical) {
m_pFlash->Draw(pTargetBitmap, targetPos, mode, onlyPhysical);
}

// Set the screen flash effect to draw at the final post processing stage
if (m_FireFrame && m_pFlash && m_pFlash->GetScreenEffect() && mode == g_DrawColor && !onlyPhysical) {
Vector muzzlePos = m_Pos + RotateOffset(m_MuzzleOff + Vector(m_pFlash->GetSpriteWidth() * 0.3F, 0));
if (!g_SceneMan.ObscuredPoint(muzzlePos)) {
g_PostProcessMan.RegisterPostEffect(muzzlePos, m_pFlash->GetScreenEffect(), m_pFlash->GetScreenEffectHash(), RandomNum(m_pFlash->GetEffectStopStrength(), m_pFlash->GetEffectStartStrength()), m_pFlash->GetEffectRotAngle());
}
}
}


Expand Down
8 changes: 4 additions & 4 deletions Entities/MOPixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ namespace RTE {
}
}
}

if (m_pScreenEffect) {
SetPostScreenEffectToDraw();
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -261,10 +265,6 @@ namespace RTE {
}

g_SceneMan.RegisterDrawing(targetBitmap, mode == g_DrawNoMOID ? g_NoMOID : m_MOID, pixelPos, 1.0F);

if (mode == g_DrawColor && m_pScreenEffect && !onlyPhysical) {
SetPostScreenEffectToDraw();
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions Entities/MOSParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ namespace RTE {

if (m_Frame >= m_FrameCount) { m_Frame = m_FrameCount - 1; }
}

if (m_pScreenEffect) { SetPostScreenEffectToDraw(); }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -221,8 +223,6 @@ namespace RTE {

g_SceneMan.RegisterDrawing(targetBitmap, mode == g_DrawNoMOID ? g_NoMOID : m_MOID, spriteX, spriteY, spriteX + m_aSprite[m_Frame]->w, spriteY + m_aSprite[m_Frame]->h);
}

if (m_pScreenEffect && mode == g_DrawColor && !onlyPhysical) { SetPostScreenEffectToDraw(); }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
24 changes: 12 additions & 12 deletions Entities/MOSRotating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ int MOSRotating::ReadProperty(const std::string_view &propName, Reader &reader)
MatchProperty("SpecialBehaviour_ClearAllAttachables", {
// This special property is used to make Attachables work with our limited serialization system, when saving the game. Note that we discard the property value here, because all that matters is whether or not we have the property.
reader.ReadPropValue();
for (std::list<Attachable *>::iterator attachableIterator = m_Attachables.begin(); attachableIterator != m_Attachables.end(); ) {
for (auto attachableIterator = m_Attachables.begin(); attachableIterator != m_Attachables.end(); ) {
Attachable *attachable = *attachableIterator;
++attachableIterator;
delete RemoveAttachable(attachable);
Expand Down Expand Up @@ -404,7 +404,7 @@ int MOSRotating::Save(Writer &writer) const
writer << (*aItr);
}
*/
for (std::list<Gib>::const_iterator gItr = m_Gibs.begin(); gItr != m_Gibs.end(); ++gItr)
for (auto gItr = m_Gibs.begin(); gItr != m_Gibs.end(); ++gItr)
{
writer.NewProperty("AddGib");
writer << (*gItr);
Expand Down Expand Up @@ -582,11 +582,11 @@ float MOSRotating::RemoveWounds(int numberOfWoundsToRemove, bool includePositive
}

void MOSRotating::DestroyScriptState() {
for (std::list<AEmitter *>::const_iterator itr = m_Wounds.begin(); itr != m_Wounds.end(); ++itr) {
for (auto itr = m_Wounds.begin(); itr != m_Wounds.end(); ++itr) {
(*itr)->DestroyScriptState();
}

for (std::list<Attachable *>::const_iterator itr = m_Attachables.begin(); itr != m_Attachables.end(); ++itr) {
for (auto itr = m_Attachables.begin(); itr != m_Attachables.end(); ++itr) {
(*itr)->DestroyScriptState();
}

Expand All @@ -605,11 +605,11 @@ void MOSRotating::Destroy(bool notInherited)
delete m_pAtomGroup;
delete m_pDeepGroup;

for (std::list<AEmitter *>::iterator itr = m_Wounds.begin(); itr != m_Wounds.end(); ++itr) {
for (auto itr = m_Wounds.begin(); itr != m_Wounds.end(); ++itr) {
delete (*itr);
}

for (std::list<Attachable *>::iterator aItr = m_Attachables.begin(); aItr != m_Attachables.end(); ++aItr) {
for (auto aItr = m_Attachables.begin(); aItr != m_Attachables.end(); ++aItr) {
if (m_HardcodedAttachableUniqueIDsAndRemovers.find((*aItr)->GetUniqueID()) == m_HardcodedAttachableUniqueIDsAndRemovers.end()) {
delete (*aItr);
}
Expand Down Expand Up @@ -1261,10 +1261,10 @@ void MOSRotating::ResetAllTimers()
{
MovableObject::ResetAllTimers();

for (std::list<AEmitter *>::iterator emitter = m_Wounds.begin(); emitter != m_Wounds.end(); ++emitter)
for (auto emitter = m_Wounds.begin(); emitter != m_Wounds.end(); ++emitter)
(*emitter)->ResetAllTimers();

for (std::list<Attachable *>::iterator attachable = m_Attachables.begin(); attachable != m_Attachables.end(); ++attachable)
for (auto attachable = m_Attachables.begin(); attachable != m_Attachables.end(); ++attachable)
(*attachable)->ResetAllTimers();
}

Expand Down Expand Up @@ -1543,7 +1543,7 @@ void MOSRotating::PostTravel()


Attachable *attachable;
for (std::list<Attachable *>::iterator attachableIterator = m_Attachables.begin(); attachableIterator != m_Attachables.end(); ) {
for (auto attachableIterator = m_Attachables.begin(); attachableIterator != m_Attachables.end(); ) {
attachable = *attachableIterator;
RTEAssert(attachable, "Broken Attachable in PostTravel!");
++attachableIterator;
Expand Down Expand Up @@ -1614,11 +1614,11 @@ void MOSRotating::Update() {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void MOSRotating::PostUpdate() {
for (std::list<AEmitter *>::const_iterator itr = m_Wounds.begin(); itr != m_Wounds.end(); ++itr) {
for (auto itr = m_Wounds.begin(); itr != m_Wounds.end(); ++itr) {
(*itr)->PostUpdate();
}

for (std::list<Attachable *>::const_iterator itr = m_Attachables.begin(); itr != m_Attachables.end(); ++itr) {
for (auto itr = m_Attachables.begin(); itr != m_Attachables.end(); ++itr) {
(*itr)->PostUpdate();
}

Expand Down Expand Up @@ -1774,7 +1774,7 @@ void MOSRotating::RemoveAndDeleteAttachable(Attachable *attachable) {

void MOSRotating::RemoveOrDestroyAllAttachables(bool destroy) {
Attachable *attachable;
for (std::list<Attachable *>::iterator attachableIterator = m_Attachables.begin(); attachableIterator != m_Attachables.end(); ) {
for (auto attachableIterator = m_Attachables.begin(); attachableIterator != m_Attachables.end(); ) {
attachable = *attachableIterator;
RTEAssert(attachable, "Broken Attachable!");
++attachableIterator;
Expand Down
6 changes: 6 additions & 0 deletions Entities/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include "Magazine.h"
#include "ThrownDevice.h"

#include "tracy/Tracy.hpp"

namespace RTE {

ConcreteClassInfo(Scene, Entity, 0);
Expand Down Expand Up @@ -2967,6 +2969,8 @@ void Scene::BlockUntilAllPathingRequestsComplete() {

void Scene::UpdatePathFinding()
{
ZoneScoped;

constexpr int nodeUpdatesPerCall = 100;
constexpr int maxUnupdatedMaterialAreas = 1000;

Expand Down Expand Up @@ -3099,6 +3103,8 @@ void Scene::Unlock()

void Scene::Update()
{
ZoneScoped;

m_PathfindingUpdated = false;

if (g_SettingsMan.BlipOnRevealUnseen())
Expand Down
Loading

0 comments on commit 5aed051

Please sign in to comment.