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_effectProgress = 0.0f;
m_effectOffset = Math::Vector(0.0f, 0.0f, 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_scriptEye = Math::Vector(0.0f, 0.0f, 0.0f);
m_scriptLookat = 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) CEngine::CEngine(CApplication *app)
: m_ambientColor(),
m_fogColor(),
m_deepView(),
m_fogStart(),
m_highlightRank(),
m_mice()
{ {
m_app = app; m_app = app;
m_device = nullptr; m_device = nullptr;
@ -108,17 +114,20 @@ CEngine::CEngine(CApplication *app)
m_backgroundCloudUp = Color(); m_backgroundCloudUp = Color();
m_backgroundCloudDown = Color(); m_backgroundCloudDown = Color();
m_backgroundFull = false; m_backgroundFull = false;
m_backgroundScale = false;
m_overFront = true; m_overFront = true;
m_overColor = Color(); m_overColor = Color();
m_overMode = ENG_RSTATE_TCOLOR_BLACK; 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_highlightTime = 0.0f;
m_eyePt = Math::Vector(0.0f, 0.0f, 0.0f); m_eyePt = Math::Vector(0.0f, 0.0f, 0.0f);
m_lookatPt = Math::Vector(0.0f, 0.0f, 1.0f); m_lookatPt = Math::Vector(0.0f, 0.0f, 1.0f);
m_drawWorld = true; m_drawWorld = true;
m_drawFront = false; m_drawFront = false;
m_particleDensity = 1.0f; m_particleDensity = 1.0f;
m_lastClippingDistance = m_clippingDistance = 1.0f; m_lastClippingDistance = 1.0f;
m_clippingDistance = 1.0f;
m_objectDetail = 1.0f; m_objectDetail = 1.0f;
m_terrainVision = 1000.0f; m_terrainVision = 1000.0f;
m_gadgetQuantity = 1.0f; m_gadgetQuantity = 1.0f;
@ -189,6 +198,11 @@ CEngine::CEngine(CApplication *app)
Math::LoadTranslationMatrix(temp2, Math::Vector(1.0f, 1.0f, 1.0f)); Math::LoadTranslationMatrix(temp2, Math::Vector(1.0f, 1.0f, 1.0f));
//m_shadowBias = Math::MultiplyMatrices(m_shadowBias, temporary); //m_shadowBias = Math::MultiplyMatrices(m_shadowBias, temporary);
m_shadowBias = Math::MultiplyMatrices(temp1, temp2); m_shadowBias = Math::MultiplyMatrices(temp1, temp2);
m_lastState = -1;
m_statisticTriangle = 0;
m_fps = 0.0f;
m_firstGroundSpot = false;
} }
CEngine::~CEngine() CEngine::~CEngine()

View File

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

View File

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

View File

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

View File

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

View File

@ -48,8 +48,6 @@ const float FOG_HSUP = 10.0f;
const float FOG_HINF = 100.0f; const float FOG_HINF = 100.0f;
//! Check if an object can be destroyed, but is not an enemy //! Check if an object can be destroyed, but is not an enemy
bool IsSoft(ObjectType type) bool IsSoft(ObjectType type)
{ {
@ -120,22 +118,9 @@ float GetDecay(ObjectType type)
return 1.0f; return 1.0f;
} }
CParticle::CParticle(CEngine* engine) 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() CParticle::~CParticle()

View File

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

View File

@ -51,15 +51,6 @@ CPyro::CPyro()
m_particle = m_engine->GetParticle(); m_particle = m_engine->GetParticle();
m_lightMan = m_engine->GetLightManager(); m_lightMan = m_engine->GetLightManager();
m_sound = CApplication::GetInstancePointer()->GetSound(); 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() CPyro::~CPyro()
@ -2375,29 +2366,28 @@ Error CPyro::FallIsEnded()
void CPyro::LightOperFlush() void CPyro::LightOperFlush()
{ {
m_lightOperTotal = 0; m_lightOper.clear();
} }
void CPyro::LightOperAdd(float progress, float intensity, float r, float g, float b) void CPyro::LightOperAdd(float progress, float intensity, float r, float g, float b)
{ {
int i = m_lightOperTotal; PyroLightOper lightOper;
m_lightOper[i].progress = progress; lightOper.progress = progress;
m_lightOper[i].intensity = intensity; lightOper.intensity = intensity;
m_lightOper[i].color.r = r; lightOper.color.r = r;
m_lightOper[i].color.g = g; lightOper.color.g = g;
m_lightOper[i].color.b = b; lightOper.color.b = b;
m_lightOperTotal++; m_lightOper.push_back(lightOper);
} }
void CPyro::LightOperFrame(float rTime) 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 ) 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 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; 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 CLight;
class CLightManager; 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 * \class CPyro
* \brief Fire effect renderer * \brief Fire effect renderer
@ -147,46 +129,61 @@ protected:
void LightOperFrame(float rTime); void LightOperFrame(float rTime);
protected: protected:
CEngine* m_engine; CEngine* m_engine = nullptr;
CTerrain* m_terrain; CTerrain* m_terrain = nullptr;
CCamera* m_camera; CCamera* m_camera = nullptr;
CParticle* m_particle; CParticle* m_particle = nullptr;
CLightManager* m_lightMan; CLightManager* m_lightMan = nullptr;
CObject* m_object; CObject* m_object = nullptr;
CRobotMain* m_main; CRobotMain* m_main = nullptr;
CSoundInterface* m_sound; CSoundInterface* m_sound = nullptr;
Math::Vector m_pos; // center of the effect Math::Vector m_pos; // center of the effect
Math::Vector m_posPower; // center of the battery Math::Vector m_posPower; // center of the battery
bool m_power; // battery exists? bool m_power = false; // battery exists?
PyroType m_type; PyroType m_type = PT_NULL;
float m_force; float m_force = 0.0f;
float m_size; float m_size = 0.0f;
float m_progress; float m_progress = 0.0f;
float m_speed; float m_speed = 0.0f;
float m_time; float m_time = 0.0f;
float m_lastParticle; float m_lastParticle = 0.0f;
float m_lastParticleSmoke; float m_lastParticleSmoke = 0.0f;
int m_soundChannel; int m_soundChannel = -1;
int m_lightRank; int m_lightRank = -1;
int m_lightOperTotal; float m_lightHeight = 0.0f;
PyroLightOper m_lightOper[10];
float m_lightHeight;
ObjectType m_burnType; struct PyroLightOper
int m_burnPartTotal; {
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]; PyroBurnPart m_burnPart[10];
int m_burnKeepPart[10]; int m_burnKeepPart[10] = {0};
float m_burnFall; float m_burnFall = 0.0f;
float m_fallFloor; float m_fallFloor = 0.0f;
float m_fallSpeed; float m_fallSpeed = 0.0f;
float m_fallBulletTime; float m_fallBulletTime = 0.0f;
bool m_fallEnding; bool m_fallEnding = false;
std::vector<Math::Sphere> m_crashSpheres; 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/parserline.h"
#include "object/level/parserparam.h" #include "object/level/parserparam.h"
#include "sound/sound.h"
// Object's constructor. // Object's constructor.

View File

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

View File

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