From 4d6e45ce0082df89746dfd8d50c500798e26ffca Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 13 May 2013 23:21:57 +0000 Subject: [PATCH] Rework a bit material panel. For some reason, the flag that tells STK to produce a water splash upon collision was placed in a dropdown among a bunch of shaders... Left old settings in place for backwards compatibility for now, some day we can remove them git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12750 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/material.cpp | 25 ++++++++++++++++++------- src/graphics/material.hpp | 13 ++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 3f9e426c1..260c7849a 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -479,7 +479,9 @@ Material::Material(const XMLNode *node, int index, bool deprecated) node->get("disable-z-write", &m_disable_z_write ); node->get("fog", &m_fog ); - node->get("mask", &m_mask); + node->get("mask", &m_mask ); + + node->get("water-splash", &m_water_splash ); if (m_collision_reaction != NORMAL) { @@ -541,7 +543,8 @@ Material::Material(const XMLNode *node, int index, bool deprecated) if (s == "water") { - m_graphical_effect = GE_WATER; + // For backwards compatibility only, eventually remove + m_water_splash = true; } else if (s == "bubble") { @@ -555,6 +558,12 @@ Material::Material(const XMLNode *node, int index, bool deprecated) node->get("grass-speed", &m_grass_speed); node->get("grass-amplitude", &m_grass_amplitude); } + else if (s == "water_shader") + { + m_graphical_effect = GE_WATER_SHADER; + node->get("water-shader-speed-1", &m_water_shader_speed_1); + node->get("water-shader-speed-2", &m_water_shader_speed_2); + } else if (s == "none") { } @@ -591,9 +600,12 @@ Material::Material(const XMLNode *node, int index, bool deprecated) node->get("splatting-lightmap", &m_splatting_lightmap); } - node->get("water-shader", &m_water_shader); - if (m_water_shader) + bool water_shader = false; + node->get("water-shader", &water_shader); + if (water_shader) { + // BACKWARDS COMPATIBILITY, eventually remove + m_graphical_effect = GE_WATER_SHADER; node->get("water-shader-speed-1", &m_water_shader_speed_1); node->get("water-shader-speed-2", &m_water_shader_speed_2); } @@ -681,7 +693,6 @@ void Material::init(unsigned int index) m_collision_reaction = NORMAL; m_add = false; m_disable_z_write = false; - m_water_shader = false; m_water_shader_speed_1 = 6.6667f; m_water_shader_speed_2 = 4.0f; m_fog = true; @@ -705,6 +716,7 @@ void Material::init(unsigned int index) m_is_heightmap = false; m_alpha_to_coverage = false; m_splatting = false; + m_water_splash = false; m_shaders.resize(SHADER_COUNT, NULL); @@ -1273,7 +1285,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m } - if (m_water_shader) + if (m_graphical_effect == GE_WATER_SHADER) { IVideoDriver* video_driver = irr_driver->getVideoDriver(); if (UserConfigParams::m_pixel_shaders && @@ -1344,7 +1356,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m grass_shaders_times_index++; } - modes++; } if (modes > 1) diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index 0ae3e7d75..4e11dca1e 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -52,12 +52,11 @@ class Material : public NoCopy { public: enum GraphicalEffect {GE_NONE, - /** Water splash effect. This is set on the seabed material. */ - GE_WATER, /** Effect where the UV texture is moved in a wave pattern */ GE_BUBBLE, /** Effect that makes grass wave as in the wind */ - GE_GRASS}; + GE_GRASS, + GE_WATER_SHADER}; enum ParticleConditions { @@ -101,6 +100,8 @@ private: * up to find the position of the actual water surface. */ bool m_below_surface; + bool m_water_splash; + /** If a kart is falling over a material with this flag set, it * will trigger the special camera fall effect. */ bool m_falling_effect; @@ -115,15 +116,13 @@ private: /** If a kart is rescued when driving on this surface. */ bool m_drive_reset; - /** If the water shader (simulating wave effects and reflexions) is enabled */ - bool m_water_shader; /** Speed of the 'main' wave in the water shader. Only used if - m_water_shader is true */ + m_graphical_effect == WATER_SHADER */ float m_water_shader_speed_1; /** Speed of the 'secondary' waves in the water shader. Only used if - m_water_shader is true */ + m_graphical_effect == WATER_SHADER */ float m_water_shader_speed_2; /** If a kart is rescued when crashing into this surface. */