Add proper initializations in remaining graphics classes

master
Piotr Dziwinski 2015-08-05 19:49:25 +02:00
parent c339838cd2
commit 0c9e745213
14 changed files with 265 additions and 331 deletions

View File

@ -148,6 +148,13 @@ CCamera::CCamera()
m_effectProgress = 0.0f;
m_effectOffset = Math::Vector(0.0f, 0.0f, 0.0f);
m_overType = CAM_OVER_EFFECT_NULL;
m_overForce = 0.0f;
m_overTime = 0.0f;
m_overMode = 0.0f;
m_overFadeIn = 0.0f;
m_overFadeOut = 0.0f;
m_scriptEye = Math::Vector(0.0f, 0.0f, 0.0f);
m_scriptLookat = Math::Vector(0.0f, 0.0f, 0.0f);

View File

@ -63,6 +63,12 @@ namespace Gfx
{
CEngine::CEngine(CApplication *app)
: m_ambientColor(),
m_fogColor(),
m_deepView(),
m_fogStart(),
m_highlightRank(),
m_mice()
{
m_app = app;
m_device = nullptr;
@ -108,17 +114,20 @@ CEngine::CEngine(CApplication *app)
m_backgroundCloudUp = Color();
m_backgroundCloudDown = Color();
m_backgroundFull = false;
m_backgroundScale = false;
m_overFront = true;
m_overColor = Color();
m_overMode = ENG_RSTATE_TCOLOR_BLACK;
m_highlightRank[0] = -1; // empty list
m_highlight = false;
std::fill_n(m_highlightRank, 100, -1);
m_highlightTime = 0.0f;
m_eyePt = Math::Vector(0.0f, 0.0f, 0.0f);
m_lookatPt = Math::Vector(0.0f, 0.0f, 1.0f);
m_drawWorld = true;
m_drawFront = false;
m_particleDensity = 1.0f;
m_lastClippingDistance = m_clippingDistance = 1.0f;
m_lastClippingDistance = 1.0f;
m_clippingDistance = 1.0f;
m_objectDetail = 1.0f;
m_terrainVision = 1000.0f;
m_gadgetQuantity = 1.0f;
@ -189,6 +198,11 @@ CEngine::CEngine(CApplication *app)
Math::LoadTranslationMatrix(temp2, Math::Vector(1.0f, 1.0f, 1.0f));
//m_shadowBias = Math::MultiplyMatrices(m_shadowBias, temporary);
m_shadowBias = Math::MultiplyMatrices(temp1, temp2);
m_lastState = -1;
m_statisticTriangle = 0;
m_fps = 0.0f;
m_firstGroundSpot = false;
}
CEngine::~CEngine()

View File

@ -155,16 +155,11 @@ struct EngineTriangle
//! Material
Material material;
//! Render state
int state;
int state = ENG_RSTATE_NORMAL;
//! 1st texture
std::string tex1Name;
//! 2nd texture
std::string tex2Name;
inline EngineTriangle()
{
state = ENG_RSTATE_NORMAL;
}
};
/**
@ -202,12 +197,12 @@ struct EngineBaseObjDataTier
unsigned int staticBufferId;
bool updateStaticBuffer;
inline EngineBaseObjDataTier(EngineTriangleType _type = ENG_TRIANGLE_TYPE_TRIANGLES,
const Material& _material = Material(),
int _state = ENG_RSTATE_NORMAL)
: type(_type)
, material(_material)
, state(_state)
inline EngineBaseObjDataTier(EngineTriangleType type = ENG_TRIANGLE_TYPE_TRIANGLES,
const Material& material = Material(),
int state = ENG_RSTATE_NORMAL)
: type(type)
, material(material)
, state(state)
, staticBufferId(0)
, updateStaticBuffer(false)
{}
@ -225,9 +220,10 @@ struct EngineBaseObjTexTier
Texture tex2;
std::vector<EngineBaseObjDataTier> next;
inline EngineBaseObjTexTier(const std::string& _tex1Name = "", const std::string& _tex2Name = "")
: tex1Name(_tex1Name)
, tex2Name(_tex2Name)
inline EngineBaseObjTexTier(const std::string& tex1Name = "",
const std::string& tex2Name = "")
: tex1Name(tex1Name)
, tex2Name(tex2Name)
{}
};
@ -240,30 +236,21 @@ struct EngineBaseObjTexTier
struct EngineBaseObject
{
//! If true, base object is valid in objects vector
bool used;
bool used = false;
//! Number of triangles
int totalTriangles;
int totalTriangles = 0;
//! Bounding box min (origin 0,0,0 always included)
Math::Vector bboxMin;
//! bounding box max (origin 0,0,0 always included)
Math::Vector bboxMax;
//! Radius of the sphere at the origin
float radius;
float radius = 0.0f;
//! Next tier (Tex)
std::vector<EngineBaseObjTexTier> next;
inline EngineBaseObject()
{
LoadDefault();
}
inline void LoadDefault()
{
used = false;
totalTriangles = 0;
bboxMax.LoadZero();
bboxMin.LoadZero();
radius = 0.0f;
*this = EngineBaseObject();
}
};
@ -274,45 +261,30 @@ struct EngineBaseObject
struct EngineObject
{
//! If true, object is valid in objects vector
bool used;
bool used = false;
//! Rank of associated base engine object
int baseObjRank;
int baseObjRank = -1;
//! If true, the object is drawn
bool visible;
bool visible = false;
//! If true, object is behind the 2D interface
bool drawWorld;
bool drawWorld = false;
//! If true, the shape is before the 2D interface
bool drawFront;
bool drawFront = false;
//! Type of object
EngineObjectType type;
EngineObjectType type = ENG_OBJTYPE_NULL;
//! Transformation matrix
Math::Matrix transform;
//! Distance to object from eye point
float distance;
float distance = 0.0f;
//! Rank of the associated shadow
int shadowRank;
int shadowRank = -1;
//! Transparency of the object [0, 1]
float transparency;
//! Calls LoadDefault()
inline EngineObject()
{
LoadDefault();
}
float transparency = 0.0f;
//! Loads default values
inline void LoadDefault()
{
used = false;
baseObjRank = -1;
visible = false;
drawWorld = false;
drawFront = false;
type = ENG_OBJTYPE_NULL;
transform.LoadIdentity();
distance = 0.0f;
shadowRank = -1;
transparency = 0.0f;
*this = EngineObject();
}
};
@ -335,40 +307,29 @@ enum EngineShadowType
struct EngineShadow
{
//! If true, shadow is valid
bool used;
bool used = false;
//! If true, shadow is invisible (object being carried for example)
bool hide;
bool hide = false;
//! Rank of the associated object
int objRank;
int objRank = -1;
//! Type of shadow
EngineShadowType type;
EngineShadowType type = ENG_SHADOW_NORM;
//! Position of the shadow
Math::Vector pos;
//! Normal to the terrain
Math::Vector normal;
//! Angle of the shadow
float angle;
float angle = 0.0f;
//! Radius of the shadow
float radius;
float radius = 0.0f;
//! Intensity of the shadow
float intensity;
float intensity = 0.0f;
//! Height from the ground
float height;
float height = 0.0f;
inline EngineShadow()
void LoadDefault()
{
LoadDefault();
}
inline void LoadDefault()
{
used = false;
hide = false;
objRank = 0;
type = ENG_SHADOW_NORM;
pos.LoadZero();
normal.LoadZero();
angle = radius = intensity = height = 0.0f;
*this = EngineShadow();
}
};
@ -379,36 +340,27 @@ struct EngineShadow
struct EngineGroundSpot
{
//! If true, ground spot is valid
bool used;
bool used = false;
//! Color of the shadow
Color color;
//! Min altitude
float min;
float min = 0.0f;
//! Max altitude
float max;
float max = 0.0f;
//! Transition area
float smooth;
float smooth = 0.0f;
//! Position for the shadow
Math::Vector pos;
//! Radius of the shadow
float radius;
float radius = 0.0f;
//! Position of the shadow drawn
Math::Vector drawPos;
//! Radius of the shadow drawn
float drawRadius;
float drawRadius = 0.0f;
inline EngineGroundSpot()
void LoadDefault()
{
LoadDefault();
}
inline void LoadDefault()
{
used = false;
color = Color();
pos.LoadZero();
drawPos.LoadZero();
min = max = smooth = radius = drawRadius = 0.0f;
*this = EngineGroundSpot();
}
};
@ -435,47 +387,35 @@ enum EngineGroundMarkPhase
struct EngineGroundMark
{
//! If true, draw mark
bool draw;
bool draw = false;
//! Phase of life
EngineGroundMarkPhase phase;
EngineGroundMarkPhase phase = ENG_GR_MARK_PHASE_NULL;
//! Times for 3 life phases
float delay[3];
float delay[3] = { 0.0f };
//! Fixed time
float fix;
float fix = 0.0f;
//! Position for marks
Math::Vector pos;
//! Radius of marks
float radius;
float radius = 0.0f;
//! Color intensity
float intensity;
float intensity = 0.0f;
//! Draw position for marks
Math::Vector drawPos;
//! Radius for marks
float drawRadius;
float drawRadius = 0.0f;
//! Draw intensity for marks
float drawIntensity;
float drawIntensity = 0.0f;
//! X dimension of table
int dx;
int dx = 0;
//! Y dimension of table
int dy;
int dy = 0;
//! Pointer to the table
char* table;
char* table = nullptr;
inline EngineGroundMark()
void LoadDefault()
{
LoadDefault();
}
inline void LoadDefault()
{
draw = false;
phase = ENG_GR_MARK_PHASE_NULL;
pos = Math::Vector();
drawPos = Math::Vector();
delay[0] = delay[1] = delay[2] = 0.0f;
fix = radius = intensity = drawRadius = drawIntensity = 0.0f;
dx = dy = 0;
table = nullptr;
*this = EngineGroundMark();
}
};
@ -558,16 +498,18 @@ struct EngineMouse
//! Hot point
Math::Point hotPoint;
inline EngineMouse(int _icon1 = -1, int _icon2 = -1, int _iconShadow = -1,
EngineRenderState _mode1 = ENG_RSTATE_NORMAL,
EngineRenderState _mode2 = ENG_RSTATE_NORMAL,
Math::Point _hotPoint = Math::Point())
: icon1(_icon1)
, icon2(_icon2)
, iconShadow(_iconShadow)
, mode1(_mode1)
, mode2(_mode2)
, hotPoint(_hotPoint)
EngineMouse(int icon1 = -1,
int icon2 = -1,
int iconShadow = -1,
EngineRenderState mode1 = ENG_RSTATE_NORMAL,
EngineRenderState mode2 = ENG_RSTATE_NORMAL,
Math::Point hotPoint = Math::Point())
: icon1(icon1)
, icon2(icon2)
, iconShadow(iconShadow)
, mode1(mode1)
, mode2(mode2)
, hotPoint(hotPoint)
{}
};
@ -1439,7 +1381,6 @@ protected:
Math::Vector m_statisticPos;
bool m_updateGeometry;
bool m_updateStaticBuffers;
int m_alphaMode;
bool m_groundSpotVisible;
bool m_shadowVisible;
bool m_dirty;

View File

@ -17,7 +17,6 @@
* along with this program. If not, see http://gnu.org/licenses
*/
#include "graphics/engine/lightning.h"
#include "app/app.h"
@ -44,16 +43,16 @@
namespace Gfx
{
namespace
{
const int LIGHTNING_SEGMENTS_COUNT = 50;
} // anonymous namespace
CLightning::CLightning(CEngine* engine)
{
m_engine = engine;
m_terrain = nullptr;
m_camera = nullptr;
m_sound = nullptr;
Flush();
}
: m_engine(engine),
m_segments(LIGHTNING_SEGMENTS_COUNT, LightningSegment())
{}
CLightning::~CLightning()
{
@ -62,15 +61,11 @@ CLightning::~CLightning()
void CLightning::Flush()
{
m_lightningExists = false;
m_phase = LP_WAIT;
m_phase = LightningPhase::Wait;
m_speed = 0.0f;
m_progress = 0.0f;
for (int i = 0; i < FLASH_SEGMENTS; i++)
{
m_shift[i] = Math::Point(0.0f, 0.0f);
m_width[i] = 1.0f;
}
std::fill(m_segments.begin(), m_segments.end(), LightningSegment());
}
bool CLightning::EventProcess(const Event &event)
@ -88,7 +83,7 @@ bool CLightning::EventFrame(const Event &event)
m_progress += event.rTime*m_speed;
if (m_phase == LP_WAIT)
if (m_phase == LightningPhase::Wait)
{
if (m_progress >= 1.0f)
{
@ -137,41 +132,41 @@ bool CLightning::EventFrame(const Event &event)
m_camera->StartOver(CAM_OVER_EFFECT_LIGHTNING, m_pos, 1.0f);
m_phase = LP_FLASH;
m_phase = LightningPhase::Flash;
m_progress = 0.0f;
m_speed = 1.0f;
}
}
}
if (m_phase == LP_FLASH)
if (m_phase == LightningPhase::Flash)
{
if (m_progress < 1.0f)
{
float max = 5.0f;
for (int i = 0; i < FLASH_SEGMENTS; i++)
for (std::size_t i = 0; i < m_segments.size(); i++)
{
max += 0.4f;
m_shift[i].x += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].x < -max ) m_shift[i].x = -max;
if ( m_shift[i].x > max ) m_shift[i].x = max;
m_segments[i].shift.x += (Math::Rand()-0.5f)*max*2.0f;
if ( m_segments[i].shift.x < -max ) m_segments[i].shift.x = -max;
if ( m_segments[i].shift.x > max ) m_segments[i].shift.x = max;
m_shift[i].y += (Math::Rand()-0.5f)*max*2.0f;
if ( m_shift[i].y < -max ) m_shift[i].y = -max;
if ( m_shift[i].y > max ) m_shift[i].y = max;
m_segments[i].shift.y += (Math::Rand()-0.5f)*max*2.0f;
if ( m_segments[i].shift.y < -max ) m_segments[i].shift.y = -max;
if ( m_segments[i].shift.y > max ) m_segments[i].shift.y = max;
m_width[i] += (Math::Rand()-0.5f)*2.0f;
if ( m_width[i] < 1.0f ) m_width[i] = 1.0f;
if ( m_width[i] > 6.0f ) m_width[i] = 6.0f;
m_segments[i].width += (Math::Rand()-0.5f)*2.0f;
if ( m_segments[i].width < 1.0f ) m_segments[i].width = 1.0f;
if ( m_segments[i].width > 6.0f ) m_segments[i].width = 6.0f;
}
m_shift[0].x = 0.0f;
m_shift[0].y = 0.0f;
m_width[0] = 0.0f;
m_segments[0].shift.x = 0.0f;
m_segments[0].shift.y = 0.0f;
m_segments[0].width = 0.0f;
}
else
{
m_phase = LP_WAIT;
m_phase = LightningPhase::Wait;
m_progress = 0.0f;
m_speed = 1.0f / (1.0f+Math::Rand()*m_delay);
}
@ -188,7 +183,7 @@ bool CLightning::Create(float sleep, float delay, float magnetic)
m_delay = delay;
m_magnetic = magnetic;
m_phase = LP_WAIT;
m_phase = LightningPhase::Wait;
m_progress = 0.0f;
m_speed = 1.0f / m_sleep;
@ -224,7 +219,7 @@ bool CLightning::SetStatus(float sleep, float delay, float magnetic, float progr
m_delay = delay;
m_magnetic = magnetic;
m_progress = progress;
m_phase = LP_WAIT;
m_phase = LightningPhase::Wait;
m_speed = 1.0f/m_sleep;
return true;
@ -233,7 +228,7 @@ bool CLightning::SetStatus(float sleep, float delay, float magnetic, float progr
void CLightning::Draw()
{
if (!m_lightningExists) return;
if (m_phase != LP_FLASH) return;
if (m_phase != LightningPhase::Flash) return;
CDevice* device = m_engine->GetDevice();
@ -259,7 +254,7 @@ void CLightning::Draw()
Math::Vector corner[4];
Vertex vertex[4];
for (int i = 0; i < FLASH_SEGMENTS-1; i++)
for (std::size_t i = 0; i < m_segments.size() - 1; i++)
{
Math::Vector p2 = p1;
p2.y += 8.0f+0.2f*i;
@ -267,26 +262,26 @@ void CLightning::Draw()
Math::Point rot;
Math::Vector p = p1;
p.x += m_width[i];
p.x += m_segments[i].width;
rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[0].x = rot.x+m_shift[i].x;
corner[0].x = rot.x+m_segments[i].shift.x;
corner[0].y = p1.y;
corner[0].z = rot.y+m_shift[i].y;
corner[0].z = rot.y+m_segments[i].shift.y;
rot = Math::RotatePoint(Math::Point(p1.x, p1.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[1].x = rot.x+m_shift[i].x;
corner[1].x = rot.x+m_segments[i].shift.x;
corner[1].y = p1.y;
corner[1].z = rot.y+m_shift[i].y;
corner[1].z = rot.y+m_segments[i].shift.y;
p = p2;
p.x += m_width[i+1];
p.x += m_segments[i+1].width;
rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a+Math::PI/2.0f, Math::Point(p.x, p.z));
corner[2].x = rot.x+m_shift[i+1].x;
corner[2].x = rot.x+m_segments[i+1].shift.x;
corner[2].y = p2.y;
corner[2].z = rot.y+m_shift[i+1].y;
corner[2].z = rot.y+m_segments[i+1].shift.y;
rot = Math::RotatePoint(Math::Point(p2.x, p2.z), a-Math::PI/2.0f, Math::Point(p.x, p.z));
corner[3].x = rot.x+m_shift[i+1].x;
corner[3].x = rot.x+m_segments[i+1].shift.x;
corner[3].y = p2.y;
corner[3].z = rot.y+m_shift[i+1].y;
corner[3].z = rot.y+m_segments[i+1].shift.y;
if (p2.y < p1.y)
{

View File

@ -24,14 +24,14 @@
#pragma once
#include "common/event.h"
#include "math/point.h"
#include "math/vector.h"
#include <vector>
class CObject;
class CSoundInterface;
struct Event;
// Graphics module namespace
@ -82,30 +82,33 @@ protected:
CObject* SearchObject(Math::Vector pos);
protected:
CEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
CSoundInterface* m_sound;
CEngine* m_engine = nullptr;
CTerrain* m_terrain = nullptr;
CCamera* m_camera = nullptr;
CSoundInterface* m_sound = nullptr;
bool m_lightningExists;
float m_sleep;
float m_delay;
float m_magnetic;
bool m_lightningExists = false;
float m_sleep = 0.0f;
float m_delay = 0.0f;
float m_magnetic = 0.0f;
float m_speed;
float m_progress;
float m_speed = 0.0f;
float m_progress = 0.0f;
Math::Vector m_pos;
enum LightningPhase
enum class LightningPhase
{
LP_WAIT,
LP_FLASH,
Wait,
Flash,
};
LightningPhase m_phase;
LightningPhase m_phase = LightningPhase::Wait;
static const short FLASH_SEGMENTS = 50;
Math::Point m_shift[FLASH_SEGMENTS];
float m_width[FLASH_SEGMENTS];
struct LightningSegment
{
Math::Point shift;
float width = 0.0f;
};
std::vector<LightningSegment> m_segments;
};

View File

@ -91,7 +91,7 @@ private:
struct ModelInfo
{
std::vector<ModelTriangle> triangles;
int baseObjRank;
int baseObjRank = -1;
};
struct FileInfo
{

View File

@ -48,8 +48,6 @@ const float FOG_HSUP = 10.0f;
const float FOG_HINF = 100.0f;
//! Check if an object can be destroyed, but is not an enemy
bool IsSoft(ObjectType type)
{
@ -120,22 +118,9 @@ float GetDecay(ObjectType type)
return 1.0f;
}
CParticle::CParticle(CEngine* engine)
: m_engine(engine)
{
m_device = nullptr;
m_engine = engine;
m_main = nullptr;
m_terrain = nullptr;
m_water = nullptr;
m_sound = nullptr;
m_uniqueStamp = 0;
m_exploGunCounter = 0;
m_lastTimeGunDel = 0.0f;
m_absTime = 0.0f;
FlushParticle();
}
CParticle::~CParticle()

View File

@ -27,7 +27,7 @@
#include "graphics/engine/engine.h"
#include "sound/sound.h"
#include "sound/sound_type.h"
class CRobotMain;
@ -187,54 +187,54 @@ enum ParticlePhase
struct Particle
{
char used; // TRUE -> particle used
char ray; // TRUE -> ray with goal
unsigned short uniqueStamp; // unique mark
short sheet; // sheet (0..n)
ParticleType type; // type PARTI*
ParticlePhase phase; // phase PARPH*
float mass; // mass of the particle (in rebounding)
float weight; // weight of the particle (for noise)
float duration; // length of life
char used = false; // TRUE -> particle used
char ray = false; // TRUE -> ray with goal
unsigned short uniqueStamp = 0; // unique mark
short sheet = 0; // sheet (0..n)
ParticleType type = {}; // type PARTI*
ParticlePhase phase = {}; // phase PARPH*
float mass = 0.0f; // mass of the particle (in rebounding)
float weight = 0.0f; // weight of the particle (for noise)
float duration = 0.0f; // length of life
Math::Vector pos; // absolute position (relative if object links)
Math::Vector goal; // goal position (if ray)
Math::Vector speed; // speed of displacement
float windSensitivity;
short bounce; // number of rebounds
float windSensitivity = 0.0f;
short bounce = 0; // number of rebounds
Math::Point dim; // dimensions of the rectangle
float zoom; // zoom (0..1)
float angle; // angle of rotation
float intensity; // intensity
float zoom = 0.0f; // zoom (0..1)
float angle = 0.0f; // angle of rotation
float intensity = 0.0f; // intensity
Math::Point texSup; // coordinated upper texture
Math::Point texInf; // coordinated lower texture
float time; // age of the particle (0..n)
float phaseTime; // age at the beginning of phase
float testTime; // time since last test
CObject* objLink; // father object (for example reactor)
CObject* objFather; // father object (for example reactor)
short objRank; // rank of the object, or -1
short trackRank; // rank of the drag
float time = 0.0f; // age of the particle (0..n)
float phaseTime = 0.0f; // age at the beginning of phase
float testTime = 0.0f; // time since last test
CObject* objLink = nullptr; // father object (for example reactor)
CObject* objFather = nullptr; // father object (for example reactor)
short objRank = 0; // rank of the object, or -1
short trackRank = 0; // rank of the drag
};
struct Track
{
char used; // TRUE -> drag used
char drawParticle;
float step; // duration of not
float last; // increase last not memorized
float intensity; // intensity at starting (0..1)
float width; // tail width
int posUsed; // number of positions in "pos"
int head; // head to write index
char used = 0; // TRUE -> drag used
char drawParticle = 0;
float step = 0.0f; // duration of not
float last = 0.0f; // increase last not memorized
float intensity = 0.0f; // intensity at starting (0..1)
float width = 0.0f; // tail width
int posUsed = 0.0f; // number of positions in "pos"
int head = 0; // head to write index
Math::Vector pos[MAXTRACKLEN];
float len[MAXTRACKLEN];
float len[MAXTRACKLEN] = {0.0f};
};
struct WheelTrace
{
ParticleType type; // type PARTI*
ParticleType type = {}; // type PARTI*
Math::Vector pos[4]; // rectangle positions
float startTime; // beginning of life
float startTime = 0.0f; // beginning of life
};
@ -351,27 +351,27 @@ protected:
void TrackDraw(int i, ParticleType type);
protected:
CEngine* m_engine;
CDevice* m_device;
CTerrain* m_terrain;
CWater* m_water;
CRobotMain* m_main;
CSoundInterface* m_sound;
CEngine* m_engine = nullptr;
CDevice* m_device = nullptr;
CTerrain* m_terrain = nullptr;
CWater* m_water = nullptr;
CRobotMain* m_main = nullptr;
CSoundInterface* m_sound = nullptr;
Particle m_particle[MAXPARTICULE*MAXPARTITYPE];
EngineTriangle m_triangle[MAXPARTICULE]; // triangle if PartiType == 0
Track m_track[MAXTRACK];
int m_wheelTraceTotal;
int m_wheelTraceIndex;
int m_wheelTraceTotal = 0;
int m_wheelTraceIndex = 0;
WheelTrace m_wheelTrace[MAXWHEELTRACE];
int m_totalInterface[MAXPARTITYPE][SH_MAX];
bool m_frameUpdate[SH_MAX];
int m_fogTotal;
int m_fog[MAXPARTIFOG];
int m_uniqueStamp;
int m_exploGunCounter;
float m_lastTimeGunDel;
float m_absTime;
int m_totalInterface[MAXPARTITYPE][SH_MAX] = {};
bool m_frameUpdate[SH_MAX] = {false};
int m_fogTotal = 0;
int m_fog[MAXPARTIFOG] = {};
int m_uniqueStamp = 0;
int m_exploGunCounter = 0;
float m_lastTimeGunDel = 0.0f;
float m_absTime = 0.0f;
};

View File

@ -51,15 +51,6 @@ CPyro::CPyro()
m_particle = m_engine->GetParticle();
m_lightMan = m_engine->GetLightManager();
m_sound = CApplication::GetInstancePointer()->GetSound();
m_object = nullptr;
m_progress = 0.0f;
m_speed = 0.0f;
m_lightRank = -1;
m_soundChannel = -1;
LightOperFlush();
m_resetAngle = 0.0f;
}
CPyro::~CPyro()
@ -2375,29 +2366,28 @@ Error CPyro::FallIsEnded()
void CPyro::LightOperFlush()
{
m_lightOperTotal = 0;
m_lightOper.clear();
}
void CPyro::LightOperAdd(float progress, float intensity, float r, float g, float b)
{
int i = m_lightOperTotal;
PyroLightOper lightOper;
m_lightOper[i].progress = progress;
m_lightOper[i].intensity = intensity;
m_lightOper[i].color.r = r;
m_lightOper[i].color.g = g;
m_lightOper[i].color.b = b;
lightOper.progress = progress;
lightOper.intensity = intensity;
lightOper.color.r = r;
lightOper.color.g = g;
lightOper.color.b = b;
m_lightOperTotal++;
m_lightOper.push_back(lightOper);
}
void CPyro::LightOperFrame(float rTime)
{
for (int i = 0; i < m_lightOperTotal; i++)
for (std::size_t i = 1; i < m_lightOper.size(); i++)
{
if ( m_progress < m_lightOper[i].progress )
{
assert(i > 0); // TODO: if assert fails, fix the code
float progress = (m_progress-m_lightOper[i-1].progress) / (m_lightOper[i].progress-m_lightOper[i-1].progress);
float intensity = m_lightOper[i-1].intensity + (m_lightOper[i].intensity-m_lightOper[i-1].intensity)*progress;

View File

@ -54,24 +54,6 @@ class CParticle;
class CLight;
class CLightManager;
struct PyroBurnPart
{
int part;
Math::Vector initialPos;
Math::Vector finalPos;
Math::Vector initialAngle;
Math::Vector finalAngle;
};
struct PyroLightOper
{
float progress;
float intensity;
Color color;
};
/**
* \class CPyro
* \brief Fire effect renderer
@ -147,46 +129,61 @@ protected:
void LightOperFrame(float rTime);
protected:
CEngine* m_engine;
CTerrain* m_terrain;
CCamera* m_camera;
CParticle* m_particle;
CLightManager* m_lightMan;
CObject* m_object;
CRobotMain* m_main;
CSoundInterface* m_sound;
CEngine* m_engine = nullptr;
CTerrain* m_terrain = nullptr;
CCamera* m_camera = nullptr;
CParticle* m_particle = nullptr;
CLightManager* m_lightMan = nullptr;
CObject* m_object = nullptr;
CRobotMain* m_main = nullptr;
CSoundInterface* m_sound = nullptr;
Math::Vector m_pos; // center of the effect
Math::Vector m_posPower; // center of the battery
bool m_power; // battery exists?
PyroType m_type;
float m_force;
float m_size;
float m_progress;
float m_speed;
float m_time;
float m_lastParticle;
float m_lastParticleSmoke;
int m_soundChannel;
bool m_power = false; // battery exists?
PyroType m_type = PT_NULL;
float m_force = 0.0f;
float m_size = 0.0f;
float m_progress = 0.0f;
float m_speed = 0.0f;
float m_time = 0.0f;
float m_lastParticle = 0.0f;
float m_lastParticleSmoke = 0.0f;
int m_soundChannel = -1;
int m_lightRank;
int m_lightOperTotal;
PyroLightOper m_lightOper[10];
float m_lightHeight;
int m_lightRank = -1;
float m_lightHeight = 0.0f;
ObjectType m_burnType;
int m_burnPartTotal;
struct PyroLightOper
{
float progress = 0.0f;
float intensity = 0.0f;
Color color;
};
std::vector<PyroLightOper> m_lightOper;
ObjectType m_burnType = OBJECT_NULL;
int m_burnPartTotal = 0;
struct PyroBurnPart
{
int part = 0;
Math::Vector initialPos;
Math::Vector finalPos;
Math::Vector initialAngle;
Math::Vector finalAngle;
};
PyroBurnPart m_burnPart[10];
int m_burnKeepPart[10];
float m_burnFall;
int m_burnKeepPart[10] = {0};
float m_burnFall = 0.0f;
float m_fallFloor;
float m_fallSpeed;
float m_fallBulletTime;
bool m_fallEnding;
float m_fallFloor = 0.0f;
float m_fallSpeed = 0.0f;
float m_fallBulletTime = 0.0f;
bool m_fallEnding = false;
std::vector<Math::Sphere> m_crashSpheres;
float m_resetAngle;
float m_resetAngle = 0.0f;
};

View File

@ -28,6 +28,7 @@
#include "object/level/parserline.h"
#include "object/level/parserparam.h"
#include "sound/sound.h"
// Object's constructor.

View File

@ -28,6 +28,7 @@
#include "physics/physics.h"
#include "sound/sound.h"
const float ENERGY_FIRE = (0.25f/2.5f); // energy consumed/shot

View File

@ -34,7 +34,7 @@
#include "physics/physics.h"
#include "sound/sound.h"

View File

@ -17,7 +17,6 @@
* along with this program. If not, see http://gnu.org/licenses
*/
#include "object/task/taskpen.h"
#include "graphics/engine/particle.h"
@ -26,6 +25,7 @@
#include "object/old_object.h"
#include "sound/sound.h"
// Object's constructor.