diff options
author | Peter Kohaut | 2018-01-14 12:12:06 +0100 |
---|---|---|
committer | Peter Kohaut | 2018-01-28 10:57:16 +0100 |
commit | 1e5f9d3078f236f306b5d868bcd52f4e47f7b512 (patch) | |
tree | 0d402af27d75064d60e4674ab3bd4c9ad08759f1 /engines/bladerunner/set_effects.cpp | |
parent | 3a937f19c0a5e347c801c62d345475be082f9e41 (diff) | |
download | scummvm-rg350-1e5f9d3078f236f306b5d868bcd52f4e47f7b512.tar.gz scummvm-rg350-1e5f9d3078f236f306b5d868bcd52f4e47f7b512.tar.bz2 scummvm-rg350-1e5f9d3078f236f306b5d868bcd52f4e47f7b512.zip |
BLADERUNNER: Added basic KIA interface
Settings works
Help works
Clue database works
Fixed code for inserting objects into scene
Reorganization of few files
Unification & code formatting of few older files
Diffstat (limited to 'engines/bladerunner/set_effects.cpp')
-rw-r--r-- | engines/bladerunner/set_effects.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/engines/bladerunner/set_effects.cpp b/engines/bladerunner/set_effects.cpp index c4038f6726..5c7b2487a8 100644 --- a/engines/bladerunner/set_effects.cpp +++ b/engines/bladerunner/set_effects.cpp @@ -37,7 +37,7 @@ SetEffects::SetEffects(BladeRunnerEngine *vm) { _fadeColor.b = 0.0f; _fadeDensity = 0.0f; - _fogsCount = 0; + _fogCount = 0; _fogs = nullptr; } @@ -45,15 +45,15 @@ SetEffects::~SetEffects() { reset(); } -void SetEffects::read(Common::ReadStream *stream, int framesCount) { +void SetEffects::read(Common::ReadStream *stream, int frameCount) { _distanceCoeficient = stream->readFloatLE(); _distanceColor.r = stream->readFloatLE(); _distanceColor.g = stream->readFloatLE(); _distanceColor.b = stream->readFloatLE(); - _fogsCount = stream->readUint32LE(); + _fogCount = stream->readUint32LE(); int i; - for (i = 0; i < _fogsCount; i++) { + for (i = 0; i < _fogCount; i++) { int type = stream->readUint32LE(); Fog *fog = nullptr; switch (type) { @@ -70,7 +70,7 @@ void SetEffects::read(Common::ReadStream *stream, int framesCount) { if (!fog) { //TODO exception, unknown fog type } else { - fog->read(stream, framesCount); + fog->read(stream, frameCount); fog->_next = _fogs; _fogs = fog; } @@ -80,13 +80,14 @@ void SetEffects::read(Common::ReadStream *stream, int framesCount) { void SetEffects::reset() { Fog *nextFog; - if (!_fogs) + if (!_fogs) { return; + } do { nextFog = _fogs->_next; - delete this->_fogs; - this->_fogs = nextFog; + delete _fogs; + _fogs = nextFog; } while (nextFog); } @@ -105,8 +106,9 @@ void SetEffects::setFadeDensity(float density) { void SetEffects::setFogColor(const char *fogName, float r, float g, float b) { Fog *fog = findFog(fogName); - if (fog == nullptr) + if (fog == nullptr) { return; + } fog->_fogColor.r = r; fog->_fogColor.g = g; @@ -115,13 +117,14 @@ void SetEffects::setFogColor(const char *fogName, float r, float g, float b) { void SetEffects::setFogDensity(const char *fogName, float density) { Fog *fog = findFog(fogName); - if (fog == nullptr) + if (fog == nullptr) { return; + } fog->_fogDensity = density; } -void SetEffects::calculateColor(Vector3 viewPosition, Vector3 position, float *outCoeficient, Color *outColor) { +void SetEffects::calculateColor(Vector3 viewPosition, Vector3 position, float *outCoeficient, Color *outColor) const { float distanceCoeficient = CLIP((position - viewPosition).length() * _distanceCoeficient, 0.0f, 1.0f); *outCoeficient = 1.0f - distanceCoeficient; @@ -129,7 +132,7 @@ void SetEffects::calculateColor(Vector3 viewPosition, Vector3 position, float *o outColor->g = _distanceColor.g * distanceCoeficient; outColor->b = _distanceColor.b * distanceCoeficient; - for (Fog *fog = this->_fogs; fog != nullptr; fog = fog->_next) { + for (Fog *fog = _fogs; fog != nullptr; fog = fog->_next) { float fogCoeficient = 0.0f; fog->calculateCoeficient(position, viewPosition, &fogCoeficient); if (fogCoeficient > 0.0f) { @@ -142,15 +145,16 @@ void SetEffects::calculateColor(Vector3 viewPosition, Vector3 position, float *o } } - *outCoeficient = *outCoeficient * (1.0f - this->_fadeDensity); - outColor->r = outColor->r * (1.0f - this->_fadeDensity) + this->_fadeColor.r * this->_fadeDensity; - outColor->g = outColor->g * (1.0f - this->_fadeDensity) + this->_fadeColor.g * this->_fadeDensity; - outColor->b = outColor->b * (1.0f - this->_fadeDensity) + this->_fadeColor.b * this->_fadeDensity; + *outCoeficient = *outCoeficient * (1.0f - _fadeDensity); + outColor->r = outColor->r * (1.0f - _fadeDensity) + _fadeColor.r * _fadeDensity; + outColor->g = outColor->g * (1.0f - _fadeDensity) + _fadeColor.g * _fadeDensity; + outColor->b = outColor->b * (1.0f - _fadeDensity) + _fadeColor.b * _fadeDensity; } -Fog *SetEffects::findFog(const char *fogName) { - if (!_fogs) +Fog *SetEffects::findFog(const char *fogName) const { + if (!_fogs) { return nullptr; + } Fog *fog = _fogs; |