Merge remote-tracking branch 'upstream/master' into perPlayerDifficulties

This commit is contained in:
Flakebi
2014-09-02 03:57:21 +02:00
16 changed files with 158 additions and 110 deletions

View File

@@ -121,9 +121,11 @@ CALLBACK
debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* msg, const void *userparam)
{
#ifdef GL_DEBUG_SEVERITY_NOTIFICATION
// ignore minor notifications sent by some drivers (notably the nvidia one)
if (severity == GL_DEBUG_SEVERITY_NOTIFICATION)
return;
#endif
switch(source)
{

View File

@@ -137,19 +137,24 @@ void LODNode::OnAnimate(u32 timeMs)
}
}
void LODNode::OnRegisterSceneNode()
void LODNode::updateVisibility(bool* shown)
{
if (!isVisible()) return;
if (m_nodes.size() == 0) return;
bool shown = false;
int level = getLevel();
if (level>=0)
for (int i = 0; i < m_nodes.size(); i++)
{
m_nodes[level]->updateAbsolutePosition();
m_nodes[level]->OnRegisterSceneNode();
shown = true;
m_nodes[i]->setVisible(i == level);
if (i == level && shown != NULL)
*shown = level;
}
}
void LODNode::OnRegisterSceneNode()
{
bool shown;
updateVisibility(&shown);
const u32 now = irr_driver->getDevice()->getTimer()->getTime();
@@ -158,6 +163,7 @@ void LODNode::OnRegisterSceneNode()
m_nodes[0]->getType() == scene::ESNT_ANIMATED_MESH) &&
now > m_last_tick)
{
int level = getLevel();
if (m_previous_visibility == WAS_HIDDEN && shown)
{
scene::IMesh* mesh;
@@ -254,20 +260,7 @@ void LODNode::OnRegisterSceneNode()
m_previous_visibility = (shown ? WAS_SHOWN : WAS_HIDDEN);
m_last_tick = now;
// If this node has children other than the LOD nodes, draw them
core::list<ISceneNode*>::Iterator it;
for (it = Children.begin(); it != Children.end(); it++)
{
if (m_nodes_set.find(*it) == m_nodes_set.end())
{
assert(*it != NULL);
if ((*it)->isVisible())
{
(*it)->OnRegisterSceneNode();
}
}
}
scene::ISceneNode::OnRegisterSceneNode();
}
void LODNode::add(int level, scene::ISceneNode* node, bool reparent)

View File

@@ -83,6 +83,8 @@ public:
int getLevel();
void updateVisibility(bool* shown = NULL);
/*
//! Returns a reference to the current relative transformation matrix.
//! This is the matrix, this scene node uses instead of scale, translation

View File

@@ -210,6 +210,8 @@ void renderInstancedMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vec
}
static GLsync m_sync;
#ifdef Multi_Draw_Indirect
template<typename Shader, MeshMaterial Mat, video::E_VERTEX_TYPE VT, typename...Args>
void multidraw1stPass(Args...args)
{
@@ -224,6 +226,7 @@ void multidraw1stPass(Args...args)
sizeof(DrawElementsIndirectCommand));
}
}
#endif
void IrrDriver::renderSolidFirstPass()
@@ -442,6 +445,7 @@ void renderInstancedMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vec
}
}
#ifdef Multi_Draw_Indirect
template<typename Shader, MeshMaterial Mat, video::E_VERTEX_TYPE VT, typename...Args>
void multidraw2ndPass(const std::vector<uint64_t> &Handles, Args... args)
{
@@ -457,6 +461,7 @@ void multidraw2ndPass(const std::vector<uint64_t> &Handles, Args... args)
sizeof(DrawElementsIndirectCommand));
}
}
#endif
void IrrDriver::renderSolidSecondPass()
@@ -910,6 +915,8 @@ void renderInstancedShadow(const std::vector<GLuint> TextureUnits, unsigned casc
}
}
#ifdef Multi_Draw_Indirect
template<typename Shader, MeshMaterial Mat, video::E_VERTEX_TYPE VT, typename...Args>
static void multidrawShadow(unsigned i, Args ...args)
{
@@ -921,6 +928,7 @@ static void multidrawShadow(unsigned i, Args ...args)
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (const void*)(ShadowPassCmd::getInstance()->Offset[i][Mat] * sizeof(DrawElementsIndirectCommand)), ShadowPassCmd::getInstance()->Size[i][Mat], sizeof(DrawElementsIndirectCommand));
}
}
#endif
void IrrDriver::renderShadows()
{

View File

@@ -7,7 +7,7 @@
#include "graphics/stkmesh.hpp"
#include "utils/ptr_vector.hpp"
class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode
class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode, public STKMeshCommon
{
protected:
bool firstTime;
@@ -17,7 +17,7 @@ protected:
core::matrix4 ModelViewProjectionMatrix;
void cleanGLMeshes();
public:
void update();
virtual void update();
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
irr::scene::ISceneManager* mgr, irr::s32 id,
const irr::core::vector3df& position = irr::core::vector3df(0,0,0),

View File

@@ -60,6 +60,18 @@ bool isObject(video::E_MATERIAL_TYPE type);
core::vector3df getWind();
class STKMeshCommon
{
protected:
PtrVector<GLMesh, REF> MeshSolidMaterial[MAT_COUNT];
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];
public:
virtual void update() = 0;
virtual bool isImmediateDraw() const { return false; }
};
template<typename T, typename... Args>
class MeshList : public Singleton<T>, public std::vector<STK::Tuple<Args...> >
{};

View File

@@ -80,7 +80,7 @@ void STKMeshSceneNode::setFirstTimeMaterial()
if (!immediate_draw)
{
InitTextures(mesh, MatType);
MeshSolidMaterials[MatType].push_back(&mesh);
MeshSolidMaterial[MatType].push_back(&mesh);
}
}
@@ -125,7 +125,7 @@ void STKMeshSceneNode::cleanGLMeshes()
}
GLmeshes.clear();
for (unsigned i = 0; i < MAT_COUNT; i++)
MeshSolidMaterials[i].clearWithoutDeleting();
MeshSolidMaterial[i].clearWithoutDeleting();
}
void STKMeshSceneNode::setMesh(irr::scene::IMesh* mesh)
@@ -241,29 +241,29 @@ void STKMeshSceneNode::render()
AbsoluteTransformation.getInverse(invmodel);
GLMesh* mesh;
for_in(mesh, MeshSolidMaterials[MAT_DEFAULT])
for_in(mesh, MeshSolidMaterial[MAT_DEFAULT])
pushVector(ListMatDefault::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
for_in(mesh, MeshSolidMaterials[MAT_ALPHA_REF])
for_in(mesh, MeshSolidMaterial[MAT_ALPHA_REF])
pushVector(ListMatAlphaRef::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
for_in(mesh, MeshSolidMaterials[MAT_SPHEREMAP])
for_in(mesh, MeshSolidMaterial[MAT_SPHEREMAP])
pushVector(ListMatSphereMap::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
for_in(mesh, MeshSolidMaterials[MAT_DETAIL])
for_in(mesh, MeshSolidMaterial[MAT_DETAIL])
pushVector(ListMatDetails::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
windDir = getWind();
for_in(mesh, MeshSolidMaterials[MAT_GRASS])
for_in(mesh, MeshSolidMaterial[MAT_GRASS])
pushVector(ListMatGrass::getInstance(), mesh, AbsoluteTransformation, invmodel, windDir);
for_in(mesh, MeshSolidMaterials[MAT_UNLIT])
for_in(mesh, MeshSolidMaterial[MAT_UNLIT])
pushVector(ListMatUnlit::getInstance(), mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
for_in(mesh, MeshSolidMaterials[MAT_SPLATTING])
for_in(mesh, MeshSolidMaterial[MAT_SPLATTING])
pushVector(ListMatSplatting::getInstance(), mesh, AbsoluteTransformation, invmodel);
for_in(mesh, MeshSolidMaterials[MAT_NORMAL_MAP])
for_in(mesh, MeshSolidMaterial[MAT_NORMAL_MAP])
pushVector(ListMatNormalMap::getInstance(), mesh, AbsoluteTransformation, invmodel, core::matrix4::EM4CONST_IDENTITY);
return;
@@ -289,7 +289,35 @@ void STKMeshSceneNode::render()
GLenum itype = mesh.IndexType;
size_t count = mesh.IndexCount;
MeshShader::ObjectPass2Shader::getInstance()->SetTextureUnits(std::vector<GLuint>{ getTextureGLuint(spareWhiteTex) });
if (UserConfigParams::m_azdo)
{
#ifdef Bindless_Texture_Support
GLuint DiffuseHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_DIFFUSE), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(DiffuseHandle))
glMakeTextureHandleResidentARB(DiffuseHandle);
GLuint SpecularHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_SPECULAR), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[1]);
if (!glIsTextureHandleResidentARB(SpecularHandle))
glMakeTextureHandleResidentARB(SpecularHandle);
GLuint SSAOHandle = glGetTextureSamplerHandleARB(irr_driver->getRenderTargetTexture(RTT_HALF1_R), MeshShader::ObjectPass2Shader::getInstance()->SamplersId[2]);
if (!glIsTextureHandleResidentARB(SSAOHandle))
glMakeTextureHandleResidentARB(SSAOHandle);
if (!mesh.TextureHandles[0])
mesh.TextureHandles[0] = glGetTextureSamplerHandleARB(getTextureGLuint(spareWhiteTex), MeshShader::TransparentFogShader::getInstance()->SamplersId[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
MeshShader::ObjectPass2Shader::getInstance()->SetTextureHandles(createVector<uint64_t>(DiffuseHandle, SpecularHandle, SSAOHandle, mesh.TextureHandles[0]));
#endif
}
else
MeshShader::ObjectPass2Shader::getInstance()->SetTextureUnits(createVector<GLuint>(
irr_driver->getRenderTargetTexture(RTT_DIFFUSE),
irr_driver->getRenderTargetTexture(RTT_SPECULAR),
irr_driver->getRenderTargetTexture(RTT_HALF1_R),
getTextureGLuint(spareWhiteTex)));
MeshShader::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix);
assert(mesh.vao);
glBindVertexArray(mesh.vao);

View File

@@ -4,11 +4,9 @@
#include "stkmesh.hpp"
#include "utils/ptr_vector.hpp"
class STKMeshSceneNode : public irr::scene::CMeshSceneNode
class STKMeshSceneNode : public irr::scene::CMeshSceneNode, public STKMeshCommon
{
protected:
PtrVector<GLMesh, REF> MeshSolidMaterials[MAT_COUNT];
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];
std::vector<GLMesh> GLmeshes;
core::matrix4 ModelViewProjectionMatrix;
core::vector3df windDir;
@@ -25,6 +23,7 @@ protected:
bool update_each_frame;
bool isDisplacement;
public:
virtual void update();
void setReloadEachFrame(bool);
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
@@ -32,10 +31,10 @@ public:
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f),
bool createGLMeshes = true);
virtual void render();
void update();
virtual void setMesh(irr::scene::IMesh* mesh);
virtual void OnRegisterSceneNode();
virtual ~STKMeshSceneNode();
virtual bool isImmediateDraw() const { return immediate_draw; }
void setIsDisplacement(bool v) {
isDisplacement = v;
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)

View File

@@ -18,61 +18,80 @@
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "graphics/rain.hpp"
#include "graphics/weather.hpp"
#include "modes/world.hpp"
#include "states_screens/race_gui.hpp"
#include "utils/random_generator.hpp"
// The rain manager
// The weather manager
Rain::Rain()
Weather::Weather(bool lightning, std::string sound)
{
m_thunder_sound = sfx_manager->createSoundSource("thunder");
m_rain_sound = sfx_manager->createSoundSource("rain");
m_lightning = lightning;
m_thunder_sound = NULL;
m_weather_sound = NULL;
if (m_lightning)
{
m_thunder_sound = sfx_manager->createSoundSource("thunder");
}
if (sound != "")
{
m_weather_sound = sfx_manager->createSoundSource(sound);
}
RandomGenerator g;
m_next_lightning = (float)g.get(35);
} // Rain
} // Weather
// ----------------------------------------------------------------------------
Rain::~Rain()
Weather::~Weather()
{
if (m_thunder_sound != NULL)
sfx_manager->deleteSFX(m_thunder_sound);
if (m_rain_sound != NULL)
sfx_manager->deleteSFX(m_rain_sound);
if (m_weather_sound != NULL)
sfx_manager->deleteSFX(m_weather_sound);
}
// ----------------------------------------------------------------------------
void Rain::update(float dt)
void Weather::update(float dt)
{
m_next_lightning -= dt;
if (m_next_lightning < 0.0f)
if (m_lightning)
{
RaceGUIBase* gui_base = World::getWorld()->getRaceGUI();
if (gui_base != NULL)
m_next_lightning -= dt;
if (m_next_lightning < 0.0f)
{
gui_base->doLightning();
if (m_thunder_sound) m_thunder_sound->play();
}
RaceGUIBase* gui_base = World::getWorld()->getRaceGUI();
RandomGenerator g;
m_next_lightning = 35 + (float)g.get(35);
if (gui_base != NULL)
{
gui_base->doLightning();
if (m_thunder_sound)
{
m_thunder_sound->play();
}
}
RandomGenerator g;
m_next_lightning = 35 + (float)g.get(35);
}
}
} // update
// ----------------------------------------------------------------------------
void Rain::playSound()
void Weather::playSound()
{
if (m_rain_sound)
if (m_weather_sound)
{
m_rain_sound->setLoop(true);
m_rain_sound->play();
m_weather_sound->setLoop(true);
m_weather_sound->play();
}
}

View File

@@ -16,20 +16,22 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef HEADER_RAIN_HPP
#define HEADER_RAIN_HPP
#ifndef HEADER_WEATHER_HPP
#define HEADER_WEATHER_HPP
class SFXBase;
class Rain
class Weather
{
bool m_lightning;
float m_next_lightning;
SFXBase* m_thunder_sound;
SFXBase* m_rain_sound;
SFXBase* m_weather_sound;
public:
Rain();
virtual ~Rain();
Weather(bool lightning, std::string sound);
virtual ~Weather();
void update(float dt);
void playSound();

View File

@@ -491,6 +491,7 @@ void DynamicRibbonWidget::clearItems()
{
m_items.clear();
m_animated_contents = false;
m_scroll_offset = 0;
}
// -----------------------------------------------------------------------------
void DynamicRibbonWidget::elementRemoved()

View File

@@ -121,7 +121,7 @@ World::World() : WorldStatus(), m_clear_color(255,100,101,140)
m_self_destruct = false;
m_schedule_tutorial = false;
m_is_network_world = false;
m_rain = NULL;
m_weather = NULL;
m_stop_music_when_dialog_open = true;
@@ -200,10 +200,10 @@ void World::init()
powerup_manager->updateWeightsForRace(num_karts);
if (UserConfigParams::m_weather_effects &&
m_track->getWeatherType() == WEATHER_RAIN)
if (UserConfigParams::m_weather_effects)
{
m_rain = new Rain();
m_weather = new Weather(m_track->getWeatherLightning(),
m_track->getWeatherSound());
}
} // init
@@ -388,8 +388,8 @@ World::~World()
delete m_race_gui;
}
if (m_rain != NULL)
delete m_rain;
if (m_weather != NULL)
delete m_weather;
for ( unsigned int i = 0 ; i < m_karts.size() ; i++ )
delete m_karts[i];
@@ -940,9 +940,9 @@ void World::update(float dt)
Camera::getCamera(i)->update(dt);
}
if (UserConfigParams::m_graphical_effects && m_rain)
if (UserConfigParams::m_graphical_effects && m_weather)
{
m_rain->update(dt);
m_weather->update(dt);
}
projectile_manager->update(dt);

View File

@@ -28,7 +28,7 @@
#include <vector>
#include <stdexcept>
#include "graphics/rain.hpp"
#include "graphics/weather.hpp"
#include "modes/world_status.hpp"
#include "race/highscores.hpp"
#include "states_screens/race_gui_base.hpp"
@@ -164,8 +164,8 @@ protected:
/** Set when the world is online and counts network players. */
bool m_is_network_world;
/** Used to show rain graphical effects. */
Rain* m_rain;
/** Used to show weather graphical effects. */
Weather* m_weather;
virtual void onGo();
@@ -350,8 +350,8 @@ public:
bool isNetworkWorld() const { return m_is_network_world; }
/** Returns a pointer to the rain. */
Rain* getRain() {return m_rain;}
/** Returns a pointer to the weather. */
Weather* getWeather() {return m_weather;}
}; // World
#endif

View File

@@ -140,9 +140,9 @@ void WorldStatus::update(const float dt)
m_track_intro_sound->play();
}
if (World::getWorld()->getRain() != NULL)
if (World::getWorld()->getWeather() != NULL)
{
World::getWorld()->getRain()->playSound();
World::getWorld()->getWeather()->playSound();
}
return;

View File

@@ -134,7 +134,8 @@ Track::Track(const std::string &filename)
m_sky_dy = 0.0f;
m_godrays_opacity = 1.0f;
m_godrays_color = video::SColor(255, 255, 255, 255);
m_weather_type = WEATHER_NONE;
m_weather_lightning = false;
m_weather_sound = "";
m_cache_track = UserConfigParams::m_cache_overworld &&
m_ident=="overworld";
m_minimap_x_scale = 1.0f;
@@ -2101,32 +2102,16 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, ModelDefin
else if (name == "weather")
{
std::string weather_particles;
std::string weather_type;
node->get("particles", &weather_particles);
node->get("type", &weather_type);
node->get("lightning", &m_weather_lightning);
node->get("sound", &m_weather_sound);
if (weather_particles.size() > 0)
{
if (weather_particles == "rain.xml")
{
m_weather_type = WEATHER_RAIN;
}
m_sky_particles =
ParticleKindManager::get()->getParticles(weather_particles);
}
else if (weather_type.size() > 0)
{
if (weather_type == "rain")
{
m_weather_type = WEATHER_RAIN;
}
else
{
Log::error("track", "Unknown weather type : '%s'",
weather_type.c_str());
}
}
else
{
Log::error("track", "Bad weather node found - ignored.\n");

View File

@@ -62,12 +62,6 @@ class XMLNode;
const int HEIGHT_MAP_RESOLUTION = 256;
enum WeatherType
{
WEATHER_NONE,
WEATHER_RAIN
};
struct OverworldForceField
{
core::vector3df m_position;
@@ -310,7 +304,8 @@ private:
ParticleKind* m_sky_particles;
/** Use a special built-in wheather */
WeatherType m_weather_type;
bool m_weather_lightning;
std::string m_weather_sound;
/** A simple class to keep information about a track mode. */
class TrackMode
@@ -566,7 +561,9 @@ public:
unsigned int getNumberOfStartPositions() const
{ return m_start_transforms.size(); }
// ------------------------------------------------------------------------
WeatherType getWeatherType () const { return m_weather_type; }
bool getWeatherLightning() {return m_weather_lightning;}
// ------------------------------------------------------------------------
std::string getWeatherSound() {return m_weather_sound;}
// ------------------------------------------------------------------------
ParticleKind* getSkyParticles () { return m_sky_particles; }
// ------------------------------------------------------------------------