Merge remote-tracking branch 'upstream/master' into walldriving
Conflicts: src/karts/kart.cpp
This commit is contained in:
commit
5912dd2dd6
14
.travis.yml
14
.travis.yml
@ -22,11 +22,19 @@ before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
|
||||
script:
|
||||
# Build commands
|
||||
- mkdir build
|
||||
- cd build
|
||||
# First a debug build:
|
||||
- mkdir build-debug
|
||||
- cd build-debug
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DCHECK_ASSETS=off
|
||||
- make VERBOSE=1 -j 4
|
||||
|
||||
# Then a release build:
|
||||
- cd ..
|
||||
- mkdir build-release
|
||||
- cd build-release
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Release -DCHECK_ASSETS=off
|
||||
- make VERBOSE=1 -j 4
|
||||
|
||||
notifications:
|
||||
irc:
|
||||
channels:
|
||||
|
@ -17,7 +17,6 @@ option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
|
||||
|
||||
if(UNIX)
|
||||
option(USE_CPP2011 "Activate C++ 2011 mode (GCC only)" OFF)
|
||||
option(USE_XRANDR "Use xrandr instead of vidmode" OFF)
|
||||
endif()
|
||||
if(MSVC)
|
||||
# Normally hide the option to build wiiuse on VS, since it depends
|
||||
@ -29,6 +28,10 @@ else()
|
||||
set(WIIUSE_BUILD ON)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
option(USE_XRANDR "Use xrandr instead of vidmode" OFF)
|
||||
endif()
|
||||
|
||||
set(STK_SOURCE_DIR "src")
|
||||
set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
@ -118,10 +121,6 @@ if(USE_FRIBIDI)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Xrandr
|
||||
if(UNIX AND USE_XRANDR)
|
||||
find_package(Xrandr REQUIRED)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
# if(USE_CPP2011)
|
||||
@ -134,13 +133,14 @@ find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
|
||||
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
|
||||
else()
|
||||
set(IRRLICHT_XF86VM_LIBRARY "")
|
||||
if(USE_XRANDR)
|
||||
find_package(Xrandr REQUIRED)
|
||||
else()
|
||||
find_library(IRRLICHT_XF86VM_LIBRARY Xxf86vm)
|
||||
mark_as_advanced(IRRLICHT_XF86VM_LIBRARY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# Set some compiler options
|
||||
if(UNIX)
|
||||
@ -153,12 +153,12 @@ if(WIN32)
|
||||
|
||||
# And shut up about unsafe stuff
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
# VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode.
|
||||
# Since STK uses DEBUG, this is added for debug compilation only:
|
||||
# VS will automatically add NDEBUG for release mode, but only _DEBUG in debug mode.
|
||||
# Since STK uses DEBUG, this is added for debug compilation only:
|
||||
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
|
||||
else()
|
||||
# All non VS generators used create only a single compile mode, so
|
||||
# compile flags can be simplye be added
|
||||
# compile flags can be simplye be added
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
add_definitions(-DDEBUG)
|
||||
else()
|
||||
@ -245,10 +245,16 @@ target_link_libraries(supertuxkart
|
||||
stkirrlicht
|
||||
${CURL_LIBRARIES}
|
||||
${OGGVORBIS_LIBRARIES}
|
||||
${IRRLICHT_XF86VM_LIBRARY}
|
||||
${OPENAL_LIBRARY}
|
||||
${OPENGL_LIBRARIES})
|
||||
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
if(USE_XRANDR)
|
||||
target_link_libraries(supertuxkart ${XRANDR_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(supertuxkart ${IRRLICHT_XF86VM_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
# In theory it would be cleaner to let CMake detect the right dependencies. In practice, this means that if a OSX user has
|
||||
@ -284,11 +290,6 @@ if(USE_WIIUSE)
|
||||
|
||||
endif()
|
||||
|
||||
# Xrandr
|
||||
if(UNIX AND USE_XRANDR)
|
||||
target_link_libraries(supertuxkart ${XRANDR_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
target_link_libraries(supertuxkart iphlpapi.lib)
|
||||
add_custom_command(TARGET supertuxkart POST_BUILD
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
||||
// Copyright (C) 2014 Dawid Gan
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
@ -234,7 +235,7 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
||||
return true;
|
||||
if (reset)
|
||||
{
|
||||
#ifdef _IRR_LINUX_X11_VIDMODE_
|
||||
#ifdef _IRR_LINUX_X11_VIDMODE_
|
||||
if (UseXVidMode && CreationParams.Fullscreen)
|
||||
{
|
||||
XF86VidModeSwitchToMode(display, screennr, &oldVideoMode);
|
||||
@ -244,9 +245,20 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
if (UseXRandR && CreationParams.Fullscreen)
|
||||
{
|
||||
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
|
||||
XRRSetScreenConfig(display,config,DefaultRootWindow(display),oldRandrMode,oldRandrRotation,CurrentTime);
|
||||
XRRFreeScreenConfigInfo(config);
|
||||
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
||||
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
|
||||
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
||||
|
||||
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
|
||||
crtc->x, crtc->y, old_mode,
|
||||
crtc->rotation, &output_id, 1);
|
||||
|
||||
XRRFreeOutputInfo(output);
|
||||
XRRFreeCrtcInfo(crtc);
|
||||
XRRFreeScreenResources(res);
|
||||
|
||||
if (s != Success)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
@ -319,30 +331,74 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
if (XRRQueryExtension(display, &eventbase, &errorbase))
|
||||
{
|
||||
s32 modeCount;
|
||||
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
|
||||
XRRScreenSize *modes=XRRConfigSizes(config,&modeCount);
|
||||
for (s32 i = 0; i<modeCount; ++i)
|
||||
{
|
||||
if (bestMode==-1 && (u32)modes[i].width >= Width && (u32)modes[i].height >= Height)
|
||||
bestMode = i;
|
||||
else if (bestMode!=-1 &&
|
||||
(u32)modes[i].width >= Width &&
|
||||
(u32)modes[i].height >= Height &&
|
||||
modes[i].width <= modes[bestMode].width &&
|
||||
modes[i].height <= modes[bestMode].height)
|
||||
bestMode = i;
|
||||
}
|
||||
if (bestMode != -1)
|
||||
{
|
||||
os::Printer::log("Starting randr fullscreen mode...", ELL_INFORMATION);
|
||||
os::Printer::log("width: ", core::stringc(modes[bestMode].width).c_str(), ELL_INFORMATION);
|
||||
os::Printer::log("height: ", core::stringc(modes[bestMode].height).c_str(), ELL_INFORMATION);
|
||||
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
||||
|
||||
XRRSetScreenConfig(display,config,DefaultRootWindow(display),bestMode,oldRandrRotation,CurrentTime);
|
||||
UseXRandR=true;
|
||||
if (!res)
|
||||
{
|
||||
CreationParams.Fullscreen = false;
|
||||
return CreationParams.Fullscreen;
|
||||
}
|
||||
XRRFreeScreenConfigInfo(config);
|
||||
|
||||
XRROutputInfo* output = XRRGetOutputInfo(display, res, output_id);
|
||||
XRRCrtcInfo* crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
||||
float refresh_rate, refresh_rate_new;
|
||||
|
||||
for (int i = 0; i < res->nmode; i++)
|
||||
{
|
||||
const XRRModeInfo* mode = &res->modes[i];
|
||||
|
||||
if (bestMode == -1 && mode->width == Width && mode->height == Height)
|
||||
{
|
||||
for (int j = 0; j < output->nmode; j++)
|
||||
{
|
||||
if (mode->id == output->modes[j])
|
||||
{
|
||||
bestMode = j;
|
||||
refresh_rate = (mode->dotClock * 1000.0) / (mode->hTotal * mode->vTotal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bestMode != -1 && mode->width == Width && mode->height == Height)
|
||||
{
|
||||
refresh_rate_new = (mode->dotClock * 1000.0) / (mode->hTotal * mode->vTotal);
|
||||
|
||||
if (refresh_rate_new <= refresh_rate)
|
||||
break;
|
||||
|
||||
for (int j = 0; j < output->nmode; j++)
|
||||
{
|
||||
if (mode->id == output->modes[j])
|
||||
{
|
||||
bestMode = j;
|
||||
refresh_rate = refresh_rate_new;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If video mode not found, try to use first available
|
||||
if (bestMode == -1)
|
||||
{
|
||||
bestMode = 0;
|
||||
}
|
||||
|
||||
Status s = XRRSetCrtcConfig(display, res, output->crtc, CurrentTime,
|
||||
crtc->x, crtc->y, output->modes[bestMode],
|
||||
crtc->rotation, &output_id, 1);
|
||||
|
||||
XRRFreeCrtcInfo(crtc);
|
||||
XRRFreeOutputInfo(output);
|
||||
XRRFreeScreenResources(res);
|
||||
|
||||
if (s != Success)
|
||||
{
|
||||
CreationParams.Fullscreen = false;
|
||||
return CreationParams.Fullscreen;
|
||||
}
|
||||
|
||||
UseXRandR=true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -351,6 +407,7 @@ bool CIrrDeviceLinux::switchToFullscreen(bool reset)
|
||||
"to switch to fullscreen mode. Running in windowed mode instead.", ELL_WARNING);
|
||||
CreationParams.Fullscreen = false;
|
||||
}
|
||||
|
||||
return CreationParams.Fullscreen;
|
||||
}
|
||||
|
||||
@ -1497,18 +1554,70 @@ video::IVideoModeList* CIrrDeviceLinux::getVideoModeList()
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
if (XRRQueryExtension(display, &eventbase, &errorbase))
|
||||
{
|
||||
int modeCount;
|
||||
XRRScreenConfiguration *config=XRRGetScreenInfo(display,DefaultRootWindow(display));
|
||||
oldRandrMode=XRRConfigCurrentConfiguration(config,&oldRandrRotation);
|
||||
XRRScreenSize *modes=XRRConfigSizes(config,&modeCount);
|
||||
VideoModeList.setDesktop(defaultDepth, core::dimension2d<u32>(
|
||||
modes[oldRandrMode].width, modes[oldRandrMode].height));
|
||||
for (int i = 0; i<modeCount; ++i)
|
||||
XRRScreenResources* res = XRRGetScreenResources(display, DefaultRootWindow(display));
|
||||
|
||||
if (!res)
|
||||
return NULL;
|
||||
|
||||
XRROutputInfo *output = NULL;
|
||||
XRRCrtcInfo* crtc = NULL;
|
||||
|
||||
for (int i = 0; i < res->noutput; i++)
|
||||
{
|
||||
VideoModeList.addMode(core::dimension2d<u32>(
|
||||
modes[i].width, modes[i].height), defaultDepth);
|
||||
output = XRRGetOutputInfo(display, res, res->outputs[i]);
|
||||
|
||||
if (!output || !output->crtc || output->connection == RR_Disconnected)
|
||||
{
|
||||
XRRFreeOutputInfo(output);
|
||||
continue;
|
||||
}
|
||||
|
||||
crtc = XRRGetCrtcInfo(display, res, output->crtc);
|
||||
|
||||
if (!crtc || crtc->x != 0 || crtc->y != 0)
|
||||
{
|
||||
XRRFreeCrtcInfo(crtc);
|
||||
XRRFreeOutputInfo(output);
|
||||
continue;
|
||||
}
|
||||
|
||||
output_id = res->outputs[i];
|
||||
break;
|
||||
}
|
||||
XRRFreeScreenConfigInfo(config);
|
||||
|
||||
if (crtc == NULL)
|
||||
{
|
||||
XRRFreeCrtcInfo(crtc);
|
||||
XRRFreeOutputInfo(output);
|
||||
XRRFreeScreenResources(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < res->nmode; i++)
|
||||
{
|
||||
const XRRModeInfo* mode = &res->modes[i];
|
||||
|
||||
for (int j = 0; j < output->nmode; j++)
|
||||
{
|
||||
if (mode->id == output->modes[j])
|
||||
{
|
||||
VideoModeList.addMode(core::dimension2d<u32>(
|
||||
mode->width, mode->height), defaultDepth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode->id == crtc->mode)
|
||||
{
|
||||
old_mode = crtc->mode;
|
||||
VideoModeList.setDesktop(defaultDepth,
|
||||
core::dimension2d<u32>(mode->width, mode->height));
|
||||
}
|
||||
}
|
||||
|
||||
XRRFreeCrtcInfo(crtc);
|
||||
XRRFreeOutputInfo(output);
|
||||
XRRFreeScreenResources(res);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -394,8 +394,8 @@ namespace irr
|
||||
XF86VidModeModeInfo oldVideoMode;
|
||||
#endif
|
||||
#ifdef _IRR_LINUX_X11_RANDR_
|
||||
SizeID oldRandrMode;
|
||||
Rotation oldRandrRotation;
|
||||
RROutput output_id;
|
||||
RRMode old_mode;
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
GLXWindow glxWin;
|
||||
|
@ -216,3 +216,15 @@ bool Addon::filterByWords(const core::stringw words) const
|
||||
|
||||
return false;
|
||||
} // filterByWords
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Deletes the icon file of this addon, and marks it to be re-downloaded (next
|
||||
* time AddonsManager::downloadIcons() is called.
|
||||
*/
|
||||
void Addon::deleteInvalidIconFile()
|
||||
{
|
||||
m_icon_ready = false;
|
||||
std::string icon = file_manager->getAddonsFile("icons/"+m_icon_basename);
|
||||
file_manager->removeFile(icon);
|
||||
m_installed = false;
|
||||
} // redownloadIcon
|
||||
|
@ -130,6 +130,8 @@ public:
|
||||
Addon() {};
|
||||
/** Initialises the object from an XML node. */
|
||||
Addon(const XMLNode &xml);
|
||||
|
||||
void deleteInvalidIconFile();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the sort order used in the comparison function. It is static, so
|
||||
* that each instance can access the sort order. */
|
||||
@ -164,7 +166,7 @@ public:
|
||||
const std::string& getIconURL() const { return m_icon_url; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the name of the icon (i.e. the basename of the url). */
|
||||
const std::string getIconBasename() const { return m_icon_basename; }
|
||||
const std::string& getIconBasename() const { return m_icon_basename; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the name of the addon. */
|
||||
const core::stringw& getDescription() const { return m_description; }
|
||||
|
@ -256,7 +256,7 @@ void AddonsManager::initAddons(const XMLNode *xml)
|
||||
Log::warn(
|
||||
"[AddonsManager] Removing '%s' which is not on the server anymore.\n",
|
||||
m_addons_list.getData()[i].getId().c_str() );
|
||||
std::string icon = m_addons_list.getData()[i].getIconBasename();
|
||||
const std::string &icon = m_addons_list.getData()[i].getIconBasename();
|
||||
std::string icon_file =file_manager->getAddonsFile("icons/"+icon);
|
||||
if(file_manager->fileExists(icon_file))
|
||||
{
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/aligned_array.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
#include "SColor.h"
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
|
@ -28,9 +28,55 @@
|
||||
#include "utils/helpers.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
#include "utils/tuple.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace RenderGeometry
|
||||
{
|
||||
struct TexUnit
|
||||
{
|
||||
GLuint m_id;
|
||||
bool m_premul_alpha;
|
||||
|
||||
TexUnit(GLuint id, bool premul_alpha)
|
||||
{
|
||||
m_id = id;
|
||||
m_premul_alpha = premul_alpha;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::vector<TexUnit> TexUnits(T curr) // required on older clang versions
|
||||
{
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, typename... R>
|
||||
std::vector<TexUnit> TexUnits(T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, typename... R>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr)
|
||||
{
|
||||
v.push_back(curr);
|
||||
}
|
||||
}
|
||||
using namespace RenderGeometry;
|
||||
|
||||
template<typename Shader, typename...uniforms>
|
||||
void draw(const GLMesh *mesh, uniforms... Args)
|
||||
@ -61,9 +107,9 @@ template<unsigned N>
|
||||
struct unroll_args_instance
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
unroll_args_instance<N - 1>::template exec<T>(Shader, t, std::get<N - 1>(t), args...);
|
||||
unroll_args_instance<N - 1>::template exec<T>(Shader, t, STK::tuple_get<N - 1>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -71,16 +117,17 @@ template<>
|
||||
struct unroll_args_instance<0>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(Shader, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, typename... TupleType>
|
||||
void apply_instance(const T *Shader, const std::tuple<TupleType...> &arg)
|
||||
void apply_instance(const T *Shader, const STK::Tuple<TupleType...> &arg)
|
||||
{
|
||||
unroll_args_instance<std::tuple_size<std::tuple<TupleType...> >::value >::template exec<T>(Shader, arg);
|
||||
unroll_args_instance<sizeof...(TupleType)>::template exec<T>(Shader, arg);
|
||||
//unroll_args_instance<STK::TupleSize<STK::Tuple<TupleType...> >::value >::template exec<T>(Shader, arg);
|
||||
}
|
||||
|
||||
template<int...List>
|
||||
@ -90,9 +137,9 @@ template<>
|
||||
struct custom_unroll_args<>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
draw<T>(Shader, std::get<0>(t), args...);
|
||||
draw<T>(Shader, STK::tuple_get<0>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -100,27 +147,27 @@ template<int N, int...List>
|
||||
struct custom_unroll_args<N, List...>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
custom_unroll_args<List...>::template exec<T>(Shader, t, std::get<N>(t), args...);
|
||||
custom_unroll_args<List...>::template exec<T>(Shader, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Shader, enum E_VERTEX_TYPE VertexType, int ...List, typename... TupleType>
|
||||
void renderMeshes1stPass(const std::vector<std::pair<GLuint, bool> > &TexUnits, std::vector<std::tuple<TupleType...> > &meshes)
|
||||
void renderMeshes1stPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
{
|
||||
glUseProgram(Shader::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(std::get<0>(meshes[i]));
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
for (unsigned j = 0; j < TexUnits.size(); j++)
|
||||
{
|
||||
if (!mesh.textures[j])
|
||||
mesh.textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
|
||||
compressTexture(mesh.textures[j], TexUnits[j].second);
|
||||
setTexture(TexUnits[j].first, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
compressTexture(mesh.textures[j], TexUnits[j].m_premul_alpha);
|
||||
setTexture(TexUnits[j].m_id, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
if (mesh.VAOType != VertexType)
|
||||
{
|
||||
@ -161,31 +208,36 @@ void IrrDriver::renderSolidFirstPass()
|
||||
|
||||
{
|
||||
ScopedGPUTimer Timer(getGPUTimer(Q_SOLID_PASS1));
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatDefault::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatSphereMap::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatUnlit::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatDetails::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>({ { MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true } }, ListMatSplatting::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>({ { MeshShader::ObjectRefPass1Shader::getInstance()->TU_tex, true } }, ListMatAlphaRef::Arguments);
|
||||
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>({ { MeshShader::GrassPass1Shader::getInstance()->TU_tex, true } }, ListMatGrass::Arguments);
|
||||
renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS, 2, 1>({ { MeshShader::NormalMapShader::getInstance()->TU_glossy, true }, { MeshShader::NormalMapShader::getInstance()->TU_normalmap, false } }, ListMatNormalMap::Arguments);
|
||||
|
||||
std::vector<TexUnit> object_pass1_texunits = TexUnits(TexUnit(MeshShader::ObjectPass1Shader::getInstance()->TU_tex, true) );
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatDefault::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatSphereMap::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_STANDARD, 2, 1>(object_pass1_texunits, ListMatUnlit::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatDetails::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectPass1Shader, video::EVT_2TCOORDS, 2, 1>(object_pass1_texunits, ListMatSplatting::Arguments);
|
||||
renderMeshes1stPass<MeshShader::ObjectRefPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::ObjectRefPass1Shader::getInstance()->TU_tex, true)), ListMatAlphaRef::Arguments);
|
||||
renderMeshes1stPass<MeshShader::GrassPass1Shader, video::EVT_STANDARD, 3, 2, 1>(TexUnits(TexUnit(MeshShader::GrassPass1Shader::getInstance()->TU_tex, true)), ListMatGrass::Arguments);
|
||||
renderMeshes1stPass<MeshShader::NormalMapShader, video::EVT_TANGENTS, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::NormalMapShader::getInstance()->TU_glossy, true),
|
||||
TexUnit(MeshShader::NormalMapShader::getInstance()->TU_normalmap, false)
|
||||
), ListMatNormalMap::Arguments);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Shader, enum E_VERTEX_TYPE VertexType, int...List, typename... TupleType>
|
||||
void renderMeshes2ndPass(const std::vector<std::pair<GLuint, bool> > &TexUnits, std::vector<std::tuple<TupleType...> > &meshes)
|
||||
void renderMeshes2ndPass(const std::vector<TexUnit> &TexUnits, std::vector<STK::Tuple<TupleType...> > &meshes)
|
||||
{
|
||||
glUseProgram(Shader::getInstance()->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < meshes.size(); i++)
|
||||
{
|
||||
GLMesh &mesh = *(std::get<0>(meshes[i]));
|
||||
GLMesh &mesh = *(STK::tuple_get<0>(meshes[i]));
|
||||
for (unsigned j = 0; j < TexUnits.size(); j++)
|
||||
{
|
||||
if (!mesh.textures[j])
|
||||
mesh.textures[j] = getUnicolorTexture(video::SColor(255, 255, 255, 255));
|
||||
compressTexture(mesh.textures[j], TexUnits[j].second);
|
||||
setTexture(TexUnits[j].first, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
compressTexture(mesh.textures[j], TexUnits[j].m_premul_alpha);
|
||||
setTexture(TexUnits[j].m_id, getTextureGLuint(mesh.textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
if (irr_driver->getLightViz())
|
||||
{
|
||||
GLint swizzleMask[] = { GL_ONE, GL_ONE, GL_ONE, GL_ALPHA };
|
||||
@ -240,14 +292,43 @@ void IrrDriver::renderSolidSecondPass()
|
||||
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 4, 3, 1>({ { MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true } }, ListMatDefault::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 4, 3, 1 >({ { MeshShader::ObjectRefPass2Shader::getInstance()->TU_Albedo, true } }, ListMatAlphaRef::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD, 4, 2, 1>({ { MeshShader::SphereMapShader::getInstance()->TU_tex, true } }, ListMatSphereMap::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 4, 1>({ { MeshShader::DetailledObjectPass2Shader::getInstance()->TU_Albedo, true }, { MeshShader::DetailledObjectPass2Shader::getInstance()->TU_detail, true } }, ListMatDetails::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD, 4, 3, 1>({ { MeshShader::GrassPass2Shader::getInstance()->TU_Albedo, true } }, ListMatGrass::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 1>({ { MeshShader::ObjectUnlitShader::getInstance()->TU_tex, true } }, ListMatUnlit::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS, 3, 1>({ { 8, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_layout, false }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail0, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail1, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail2, true }, { MeshShader::SplattingShader::getInstance()->TU_tex_detail3, true } }, ListMatSplatting::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS, 4, 3, 1>({ { MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true } }, ListMatNormalMap::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_STANDARD, 4, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatDefault::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectRefPass2Shader, video::EVT_STANDARD, 4, 3, 1 >(TexUnits(
|
||||
TexUnit(MeshShader::ObjectRefPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatAlphaRef::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::SphereMapShader, video::EVT_STANDARD, 4, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::SphereMapShader::getInstance()->TU_tex, true)
|
||||
), ListMatSphereMap::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::DetailledObjectPass2Shader, video::EVT_2TCOORDS, 4, 1>(TexUnits(
|
||||
TexUnit(MeshShader::DetailledObjectPass2Shader::getInstance()->TU_Albedo, true),
|
||||
TexUnit(MeshShader::DetailledObjectPass2Shader::getInstance()->TU_detail, true)
|
||||
), ListMatDetails::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::GrassPass2Shader, video::EVT_STANDARD, 4, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::GrassPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatGrass::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectUnlitShader, video::EVT_STANDARD, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectUnlitShader::getInstance()->TU_tex, true)
|
||||
), ListMatUnlit::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::SplattingShader, video::EVT_2TCOORDS, 3, 1>(TexUnits(
|
||||
TexUnit(8, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_layout, false),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail0, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail1, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail2, true),
|
||||
TexUnit(MeshShader::SplattingShader::getInstance()->TU_tex_detail3, true)
|
||||
), ListMatSplatting::Arguments);
|
||||
|
||||
renderMeshes2ndPass<MeshShader::ObjectPass2Shader, video::EVT_TANGENTS, 4, 3, 1>(TexUnits(
|
||||
TexUnit(MeshShader::ObjectPass2Shader::getInstance()->TU_Albedo, true)
|
||||
), ListMatNormalMap::Arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,16 +355,24 @@ void IrrDriver::renderTransparent()
|
||||
if (World::getWorld() && World::getWorld()->isFogEnabled())
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>({ { MeshShader::TransparentFogShader::getInstance()->TU_tex, true } }, ListBlendTransparentFog::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentFogShader::getInstance()->TU_tex, true)
|
||||
), ListBlendTransparentFog::Arguments);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>({ { MeshShader::TransparentFogShader::getInstance()->TU_tex, true } }, ListAdditiveTransparentFog::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentFogShader, video::EVT_STANDARD, 8, 7, 6, 5, 4, 3, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentFogShader::getInstance()->TU_tex, true)
|
||||
), ListAdditiveTransparentFog::Arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>({ { MeshShader::TransparentShader::getInstance()->TU_tex, true } }, ListBlendTransparent::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentShader::getInstance()->TU_tex, true)
|
||||
), ListBlendTransparent::Arguments);
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>({ { MeshShader::TransparentShader::getInstance()->TU_tex, true } }, ListAdditiveTransparent::Arguments);
|
||||
renderMeshes2ndPass<MeshShader::TransparentShader, video::EVT_STANDARD, 2, 1>(TexUnits(
|
||||
TexUnit(MeshShader::TransparentShader::getInstance()->TU_tex, true)
|
||||
), ListAdditiveTransparent::Arguments);
|
||||
}
|
||||
|
||||
if (!UserConfigParams::m_dynamic_lights)
|
||||
@ -313,8 +402,8 @@ void IrrDriver::renderTransparent()
|
||||
irr_driver->getFBO(FBO_TMP1_WITH_DS).Bind();
|
||||
for (unsigned i = 0; i < ListDisplacement::Arguments.size(); i++)
|
||||
{
|
||||
const GLMesh &mesh = *(std::get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = std::get<1>(ListDisplacement::Arguments[i]);
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::Arguments[i]);
|
||||
if (mesh.VAOType != video::EVT_2TCOORDS)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
@ -337,8 +426,8 @@ void IrrDriver::renderTransparent()
|
||||
displaceTex = irr_driver->getTexture(FileManager::TEXTURE, "displace.png");
|
||||
for (unsigned i = 0; i < ListDisplacement::Arguments.size(); i++)
|
||||
{
|
||||
const GLMesh &mesh = *(std::get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = std::get<1>(ListDisplacement::Arguments[i]);
|
||||
const GLMesh &mesh = *(STK::tuple_get<0>(ListDisplacement::Arguments[i]));
|
||||
const core::matrix4 &AbsoluteTransformation = STK::tuple_get<1>(ListDisplacement::Arguments[i]);
|
||||
if (mesh.VAOType != video::EVT_2TCOORDS)
|
||||
continue;
|
||||
|
||||
@ -384,9 +473,9 @@ template<>
|
||||
struct shadow_custom_unroll_args<>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
drawShadow<T>(Shader, std::get<0>(t), args...);
|
||||
drawShadow<T>(Shader, STK::tuple_get<0>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -394,20 +483,20 @@ template<int N, int...List>
|
||||
struct shadow_custom_unroll_args<N, List...>
|
||||
{
|
||||
template<typename T, typename ...TupleTypes, typename ...Args>
|
||||
static void exec(const T *Shader, const std::tuple<TupleTypes...> &t, Args... args)
|
||||
static void exec(const T *Shader, const STK::Tuple<TupleTypes...> &t, Args... args)
|
||||
{
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t, std::get<N>(t), args...);
|
||||
shadow_custom_unroll_args<List...>::template exec<T>(Shader, t, STK::tuple_get<N>(t), args...);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, enum E_VERTEX_TYPE VertexType, int...List, typename... Args>
|
||||
void renderShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const std::vector<std::tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
void renderShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
{
|
||||
glUseProgram(Shader->Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
{
|
||||
const GLMesh *mesh = std::get<0>(t[i]);
|
||||
const GLMesh *mesh = STK::tuple_get<0>(t[i]);
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
compressTexture(mesh->textures[j], true);
|
||||
@ -419,13 +508,13 @@ void renderShadow(const T *Shader, const std::vector<GLuint> TextureUnits, const
|
||||
}
|
||||
|
||||
template<enum E_VERTEX_TYPE VertexType, typename... Args>
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<std::tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> TextureUnits, const std::vector<STK::Tuple<GLMesh *, core::matrix4, Args...> >&t)
|
||||
{
|
||||
glUseProgram(MeshShader::RSMShader::Program);
|
||||
glBindVertexArray(getVAO(VertexType));
|
||||
for (unsigned i = 0; i < t.size(); i++)
|
||||
{
|
||||
GLMesh *mesh = std::get<0>(t[i]);
|
||||
GLMesh *mesh = STK::tuple_get<0>(t[i]);
|
||||
for (unsigned j = 0; j < TextureUnits.size(); j++)
|
||||
{
|
||||
if (!mesh->textures[j])
|
||||
@ -433,7 +522,7 @@ void drawRSM(const core::matrix4 & rsm_matrix, const std::vector<GLuint> Texture
|
||||
compressTexture(mesh->textures[j], true);
|
||||
setTexture(TextureUnits[j], getTextureGLuint(mesh->textures[j]), GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
|
||||
}
|
||||
draw<MeshShader::RSMShader>(mesh, rsm_matrix, std::get<1>(t[i]));
|
||||
draw<MeshShader::RSMShader>(mesh, rsm_matrix, STK::tuple_get<1>(t[i]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,14 +550,15 @@ void IrrDriver::renderShadows()
|
||||
ListMatSplatting::Arguments.clear();
|
||||
m_scene_manager->drawAll(scene::ESNRP_SOLID);
|
||||
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, {}, ListMatDefault::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, {}, ListMatSphereMap::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, {}, ListMatUnlit::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, {}, ListMatDetails::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, {}, ListMatSplatting::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(MeshShader::ShadowShaderInstance, {}, ListMatNormalMap::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(MeshShader::RefShadowShaderInstance, { MeshShader::RefShadowShaderInstance->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(MeshShader::GrassShadowShaderInstance, { MeshShader::GrassShadowShaderInstance->TU_tex }, ListMatGrass::Arguments);
|
||||
std::vector<GLuint> noTexUnits;
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatDefault::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatSphereMap::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_STANDARD, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatUnlit::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatDetails::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_2TCOORDS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatSplatting::Arguments);
|
||||
renderShadow<MeshShader::ShadowShader, EVT_TANGENTS, 1>(MeshShader::ShadowShaderInstance, noTexUnits, ListMatNormalMap::Arguments);
|
||||
renderShadow<MeshShader::RefShadowShader, EVT_STANDARD, 1>(MeshShader::RefShadowShaderInstance, std::vector<GLuint>{ MeshShader::RefShadowShaderInstance->TU_tex }, ListMatAlphaRef::Arguments);
|
||||
renderShadow<MeshShader::GrassShadowShader, EVT_STANDARD, 3, 1>(MeshShader::GrassShadowShaderInstance, std::vector<GLuint>{ MeshShader::GrassShadowShaderInstance->TU_tex }, ListMatGrass::Arguments);
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
@ -478,9 +568,9 @@ void IrrDriver::renderShadows()
|
||||
m_rtts->getRSM().Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, { MeshShader::RSMShader::TU_tex }, ListMatSplatting::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDefault::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSphereMap::Arguments);
|
||||
drawRSM<EVT_STANDARD>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatUnlit::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatDetails::Arguments);
|
||||
drawRSM<EVT_2TCOORDS>(rsm_matrix, std::vector<GLuint>{ MeshShader::RSMShader::TU_tex }, ListMatSplatting::Arguments);
|
||||
}
|
||||
|
@ -14,6 +14,65 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
/**
|
||||
\page shaders_overview Shaders Overview
|
||||
|
||||
\section shader_declaration Shader declaration
|
||||
You need to create a class for each shader in shaders.cpp
|
||||
This class should inherit from the template ShaderHelper<>.
|
||||
The template first parameter is the shader class being declared and the following ones are the types
|
||||
of every uniform (except samplers) required by the shaders.
|
||||
|
||||
The template inheritance will provide the shader with a setUniforms() variadic function which calls
|
||||
the glUniform*() that pass uniforms value to the shader according to the type given as parameter
|
||||
to the template.
|
||||
|
||||
The class constructor is used to
|
||||
\li \ref shader_declaration_compile
|
||||
\li \ref shader_declaration_uniform_names
|
||||
\li \ref shader_declaration_bind_texture_unit
|
||||
|
||||
Of course it's possible to use the constructor to declare others things if needed.
|
||||
|
||||
\subsection shader_declaration_compile Compile the shader
|
||||
|
||||
The LoadProgram() function is provided to ease shader compilation and link.
|
||||
|
||||
\subsection shader_declaration_uniform_names Declare uniforms
|
||||
|
||||
\subsection shader_declaration_bind_texture_unit Bind texture unit and name
|
||||
|
||||
\section shader_usage
|
||||
|
||||
Shader's class are singleton that can be retrieved using ShaderClassName::getInstance() which automatically
|
||||
creates an instance the first time it is called.
|
||||
|
||||
As the program id of a shader instance is public it can be used to bind a program :
|
||||
\code
|
||||
glUseProgram(MyShaderClass::getInstance()->Program);
|
||||
\endcode
|
||||
|
||||
To set uniforms use the automatically generated function setUniforms:
|
||||
|
||||
\code
|
||||
MyShaderClass::getInstance()->setUniforms(Args...)
|
||||
\endcode
|
||||
|
||||
A Vertex Array must be bound (VAO creation process is currently left to the reader) :
|
||||
|
||||
\code
|
||||
glBindVertexAttrib(vao);
|
||||
\endcode
|
||||
|
||||
To actually perform the rendering you also need to call a glDraw* function (left to the reader as well) :
|
||||
|
||||
\code
|
||||
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT);
|
||||
\endcode
|
||||
|
||||
*/
|
||||
|
||||
#define SHADER_NAMES
|
||||
|
||||
#include "graphics/callbacks.hpp"
|
||||
@ -28,6 +87,11 @@
|
||||
|
||||
using namespace video;
|
||||
|
||||
GLuint getUniformLocation(GLuint program, const char* name)
|
||||
{
|
||||
return glGetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
Shaders::Shaders()
|
||||
{
|
||||
// Callbacks
|
||||
@ -429,28 +493,79 @@ namespace UtilShader
|
||||
glUniform4i(uniform_color, col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
glUniformMatrix4fv(glGetUniformLocation(Program, "ModelMatrix"), 1, GL_FALSE, core::IdentityMatrix.pointer());
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
AssignTextureUnit(GLuint Program, const std::vector<std::pair<GLuint, const char*> > assoc)
|
||||
{
|
||||
glUseProgram(Program);
|
||||
for (unsigned i = 0; i < assoc.size(); i++)
|
||||
struct TexUnit
|
||||
{
|
||||
GLuint uniform = glGetUniformLocation(Program, assoc[i].second);
|
||||
glUniform1i(uniform, assoc[i].first);
|
||||
GLuint m_index;
|
||||
const char* m_uniform;
|
||||
|
||||
TexUnit(GLuint index, const char* uniform)
|
||||
{
|
||||
m_index = index;
|
||||
m_uniform = uniform;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::vector<TexUnit> TexUnits(T curr) // required on older clang versions
|
||||
{
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
return v;
|
||||
}
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
static void
|
||||
AssignUniforms(GLuint Program, std::vector<GLuint> &uniforms, const std::vector<const char*> &name)
|
||||
{
|
||||
for (unsigned i = 0; i < name.size(); i++)
|
||||
template <typename T, typename... R>
|
||||
std::vector<TexUnit> TexUnits(T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
uniforms.push_back(glGetUniformLocation(Program, name[i]));
|
||||
std::vector<TexUnit> v;
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename T, typename... R>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr, R... rest) // required on older clang versions
|
||||
{
|
||||
v.push_back(curr);
|
||||
VTexUnits(v, rest...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void VTexUnits(std::vector<TexUnit>& v, T curr)
|
||||
{
|
||||
v.push_back(curr);
|
||||
}
|
||||
|
||||
static void
|
||||
AssignTextureUnit(GLuint Program, TexUnit texUnit)
|
||||
{
|
||||
glUseProgram(Program);
|
||||
GLuint uniform = glGetUniformLocation(Program, texUnit.m_uniform);
|
||||
glUniform1i(uniform, texUnit.m_index);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
static void AssignTextureUnit(GLuint Program, TexUnit texUnit, T... rest)
|
||||
{
|
||||
glUseProgram(Program);
|
||||
GLuint uniform = glGetUniformLocation(Program, texUnit.m_uniform);
|
||||
glUniform1i(uniform, texUnit.m_index);
|
||||
AssignTextureUnit_Sub(Program, rest...);
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
static void AssignTextureUnit_Sub(GLuint Program) {}
|
||||
|
||||
template<typename... T>
|
||||
static void AssignTextureUnit_Sub(GLuint Program, TexUnit texUnit, T... rest)
|
||||
{
|
||||
GLuint uniform = glGetUniformLocation(Program, texUnit.m_uniform);
|
||||
glUniform1i(uniform, texUnit.m_index);
|
||||
AssignTextureUnit_Sub(Program, rest...);
|
||||
}
|
||||
}
|
||||
using namespace UtilShader;
|
||||
|
||||
void glUniformMatrix4fvWraper(GLuint a, size_t b, unsigned c, const float *d)
|
||||
{
|
||||
@ -474,7 +589,6 @@ void glUniform1fWrapper(GLuint a, float b)
|
||||
|
||||
namespace MeshShader
|
||||
{
|
||||
|
||||
// Solid Normal and depth pass shaders
|
||||
ObjectPass1Shader::ObjectPass1Shader()
|
||||
{
|
||||
@ -482,14 +596,14 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "InverseModelMatrix"});
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
ObjectRefPass1Shader::ObjectRefPass1Shader()
|
||||
@ -498,14 +612,14 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "InverseModelMatrix", "TextureMatrix" });
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "TextureMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
GrassPass1Shader::GrassPass1Shader()
|
||||
@ -514,9 +628,9 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "InverseModelMatrix", "windDir" });
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "windDir");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
NormalMapShader::NormalMapShader()
|
||||
@ -525,7 +639,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/normalmap.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/normalmap.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "InverseModelMatrix"});
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -533,7 +647,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_normalmap = 1;
|
||||
TU_glossy = 0;
|
||||
AssignTextureUnit(Program, { { TU_normalmap, "normalMap" }, { TU_glossy, "DiffuseForAlpha" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_normalmap, "normalMap"), TexUnit(TU_glossy, "DiffuseForAlpha"));
|
||||
}
|
||||
|
||||
InstancedObjectPass1Shader::InstancedObjectPass1Shader()
|
||||
@ -544,7 +658,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -562,7 +676,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -579,9 +693,9 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_grass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/encode_normal.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass1.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "windDir" });
|
||||
AssignUniforms("windDir");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -598,7 +712,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "TextureMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -606,7 +720,12 @@ namespace MeshShader
|
||||
}
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
}
|
||||
|
||||
ObjectPass2Shader *ObjectPass2ShaderInstance;
|
||||
@ -618,10 +737,15 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ambient" });
|
||||
AssignUniforms("ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
@ -639,10 +763,15 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ambient" });
|
||||
AssignUniforms("ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -656,13 +785,19 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/detailledobject_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "ambient");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_Albedo = 3;
|
||||
TU_detail = 4;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" }, { TU_detail, "Detail" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo"),
|
||||
TexUnit(TU_detail, "Detail")
|
||||
);
|
||||
}
|
||||
|
||||
DetailledObjectPass2Shader *DetailledObjectPass2ShaderInstance;
|
||||
@ -672,7 +807,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix" });
|
||||
AssignUniforms("ModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -680,7 +815,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
ObjectUnlitShader *ObjectUnlitShaderInstance;
|
||||
@ -691,7 +826,7 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectref_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "TextureMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -699,7 +834,12 @@ namespace MeshShader
|
||||
}
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
}
|
||||
|
||||
ObjectRefPass2Shader *ObjectRefPass2ShaderInstance;
|
||||
@ -710,10 +850,15 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/grass_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "windDir", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "windDir", "ambient");
|
||||
TU_Albedo = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo")
|
||||
);
|
||||
}
|
||||
|
||||
GrassPass2Shader *GrassPass2ShaderInstance;
|
||||
@ -725,11 +870,17 @@ namespace MeshShader
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/instanced_grass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/grass_pass2.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "windDir", "SunDir", "ambient" });
|
||||
AssignUniforms("windDir", "SunDir", "ambient");
|
||||
TU_Albedo = 3;
|
||||
TU_dtex = 4;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_Albedo, "Albedo" }, { TU_dtex, "dtex" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_Albedo, "Albedo"),
|
||||
TexUnit(TU_dtex, "dtex")
|
||||
);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -744,7 +895,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getLightFactor.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getPosFromUVDepth.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/objectpass_spheremap.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "InverseModelMatrix", "ambient" });
|
||||
AssignUniforms("ModelMatrix", "InverseModelMatrix", "ambient");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -752,7 +903,12 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 3;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_tex, "tex")
|
||||
);
|
||||
}
|
||||
|
||||
SphereMapShader *SphereMapShaderInstance;
|
||||
@ -762,15 +918,23 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/splatting.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "ambient"});
|
||||
AssignUniforms("ModelMatrix", "ambient");
|
||||
TU_tex_layout = 3;
|
||||
TU_tex_detail0 = 4;
|
||||
TU_tex_detail1 = 5;
|
||||
TU_tex_detail2 = 6;
|
||||
TU_tex_detail3 = 7;
|
||||
|
||||
AssignTextureUnit(Program, { { 0, "DiffuseMap" }, { 1, "SpecularMap" }, { 2, "SSAO" }, { TU_tex_layout, "tex_layout" },
|
||||
{ TU_tex_detail0, "tex_detail0" }, { TU_tex_detail1, "tex_detail1" }, { TU_tex_detail2, "tex_detail2" }, { TU_tex_detail3, "tex_detail3" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(0, "DiffuseMap"),
|
||||
TexUnit(1, "SpecularMap"),
|
||||
TexUnit(2, "SSAO"),
|
||||
TexUnit(TU_tex_layout, "tex_layout"),
|
||||
TexUnit(TU_tex_detail0, "tex_detail0"),
|
||||
TexUnit(TU_tex_detail1, "tex_detail1"),
|
||||
TexUnit(TU_tex_detail2, "tex_detail2"),
|
||||
TexUnit(TU_tex_detail3, "tex_detail3")
|
||||
);
|
||||
}
|
||||
|
||||
SplattingShader *SplattingShaderInstance;
|
||||
@ -804,7 +968,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, {"ModelMatrix", "TextureMatrix" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -812,7 +976,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
TransparentShader *TransparentShaderInstance;
|
||||
@ -822,7 +986,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparentfog.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col" });
|
||||
AssignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH", "endH", "start", "end", "col");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -830,7 +994,7 @@ namespace MeshShader
|
||||
}
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
}
|
||||
|
||||
TransparentFogShader *TransparentFogShaderInstance;
|
||||
@ -915,7 +1079,7 @@ namespace MeshShader
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
|
||||
}
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix" });
|
||||
AssignUniforms("ModelMatrix");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -936,7 +1100,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/rsm.frag").c_str());
|
||||
uniform_MM = glGetUniformLocation(Program, "ModelMatrix");
|
||||
uniform_RSMMatrix = glGetUniformLocation(Program, "RSMMatrix");
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
void RSMShader::setUniforms(const core::matrix4 &RSMMatrix, const core::matrix4 &ModelMatrix)
|
||||
@ -989,12 +1153,12 @@ namespace MeshShader
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix" });
|
||||
AssignUniforms("ModelMatrix");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
RefShadowShader *RefShadowShaderInstance;
|
||||
@ -1020,7 +1184,7 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -1045,12 +1209,12 @@ namespace MeshShader
|
||||
GL_GEOMETRY_SHADER, file_manager->getAsset("shaders/shadow.geom").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "windDir" });
|
||||
AssignUniforms("ModelMatrix", "windDir");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
TU_tex = 0;
|
||||
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, { TexUnit(TU_tex, "tex") });
|
||||
}
|
||||
|
||||
GrassShadowShader *GrassShadowShaderInstance;
|
||||
@ -1076,9 +1240,9 @@ namespace MeshShader
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/object_unlit.frag").c_str());
|
||||
}
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, { { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
|
||||
AssignUniforms(Program, uniforms, { "windDir" });
|
||||
AssignUniforms("windDir");
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -1090,7 +1254,7 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/white.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix"});
|
||||
AssignUniforms("ModelMatrix");
|
||||
if (!UserConfigParams::m_ubo_disabled)
|
||||
{
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
@ -1106,12 +1270,17 @@ namespace MeshShader
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/displace.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/displace.frag").c_str());
|
||||
AssignUniforms(Program, uniforms, { "ModelMatrix", "dir", "dir2" });
|
||||
AssignUniforms("ModelMatrix", "dir", "dir2");
|
||||
TU_displacement_tex = 0;
|
||||
TU_color_tex = 1;
|
||||
TU_mask_tex = 2;
|
||||
TU_tex = 3;
|
||||
AssignTextureUnit(Program, { { TU_displacement_tex, "displacement_tex" }, { TU_color_tex, "color_tex" }, { TU_mask_tex, "mask_tex" }, { TU_tex, "tex" } });
|
||||
AssignTextureUnit(Program,
|
||||
TexUnit(TU_displacement_tex, "displacement_tex"),
|
||||
TexUnit(TU_color_tex, "color_tex"),
|
||||
TexUnit(TU_mask_tex, "mask_tex"),
|
||||
TexUnit(TU_tex, "tex")
|
||||
);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
|
@ -103,12 +103,26 @@ struct UniformHelper
|
||||
};
|
||||
|
||||
void bypassUBO(GLuint Program);
|
||||
GLuint getUniformLocation(GLuint program, const char* name);
|
||||
|
||||
template<typename... Args>
|
||||
class ShaderHelper
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> uniforms;
|
||||
|
||||
void AssignUniforms(const char* name)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
void AssignUniforms(const char* name, T... rest)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
AssignUniforms(rest...);
|
||||
}
|
||||
|
||||
public:
|
||||
GLuint Program;
|
||||
|
||||
@ -125,6 +139,19 @@ class ShaderHelperSingleton : public Singleton<T>
|
||||
{
|
||||
protected:
|
||||
std::vector<GLuint> uniforms;
|
||||
|
||||
void AssignUniforms(const char* name)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
}
|
||||
|
||||
template<typename... U>
|
||||
void AssignUniforms(const char* name, U... rest)
|
||||
{
|
||||
uniforms.push_back(getUniformLocation(Program, name));
|
||||
AssignUniforms(rest...);
|
||||
}
|
||||
|
||||
public:
|
||||
friend class Singleton<class ObjectPass1Shader>;
|
||||
GLuint Program;
|
||||
|
@ -181,11 +181,11 @@ void STKAnimatedMesh::render()
|
||||
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
ListBlendTransparentFog::Arguments.push_back(
|
||||
std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
STK::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col));
|
||||
for_in(mesh, TransparentMesh[TM_ADDITIVE])
|
||||
ListAdditiveTransparentFog::Arguments.push_back(
|
||||
std::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
STK::make_tuple(mesh, AbsoluteTransformation, mesh->TextureMatrix,
|
||||
fogmax, startH, endH, start, end, col));
|
||||
}
|
||||
else
|
||||
|
@ -293,17 +293,17 @@ bool isObject(video::E_MATERIAL_TYPE type)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDefault::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatAlphaRef::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatSphereMap::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDetails::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > ListMatGrass::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatUnlit::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListMatSplatting::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatNormalMap::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDefault::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatAlphaRef::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatSphereMap::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatDetails::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > ListMatGrass::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListMatUnlit::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > ListMatSplatting::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > ListMatNormalMap::Arguments;
|
||||
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListBlendTransparent::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > ListAdditiveTransparent::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListBlendTransparentFog::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListAdditiveTransparentFog::Arguments;
|
||||
std::vector<std::tuple<GLMesh *, core::matrix4> > ListDisplacement::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListBlendTransparent::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > ListAdditiveTransparent::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListBlendTransparentFog::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > ListAdditiveTransparentFog::Arguments;
|
||||
std::vector<STK::Tuple<GLMesh *, core::matrix4> > ListDisplacement::Arguments;
|
@ -3,12 +3,12 @@
|
||||
|
||||
#include "graphics/glwrap.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "utils/tuple.hpp"
|
||||
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <IMesh.h>
|
||||
#include "../lib/irrlicht/source/Irrlicht/CMeshSceneNode.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
enum MeshMaterial
|
||||
@ -62,80 +62,80 @@ core::vector3df getWind();
|
||||
class ListMatDefault
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatAlphaRef
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatNormalMap
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatGrass
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::vector3df, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatSphereMap
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatSplatting
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatUnlit
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
class ListMatDetails
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, core::matrix4, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
|
||||
class ListBlendTransparent
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
class ListAdditiveTransparent
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
class ListBlendTransparentFog
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListAdditiveTransparentFog
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4, core::matrix4, float, float, float, float, float, video::SColorf> > Arguments;
|
||||
};
|
||||
|
||||
class ListDisplacement
|
||||
{
|
||||
public:
|
||||
static std::vector<std::tuple<GLMesh *, core::matrix4> > Arguments;
|
||||
static std::vector<STK::Tuple<GLMesh *, core::matrix4> > Arguments;
|
||||
};
|
||||
|
||||
// Forward pass (for transparents meshes)
|
||||
|
@ -6,9 +6,10 @@
|
||||
#include <IMaterialRenderer.h>
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/callbacks.hpp"
|
||||
#include "utils/helpers.hpp"
|
||||
#include "graphics/camera.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "utils/helpers.hpp"
|
||||
#include "utils/tuple.hpp"
|
||||
|
||||
STKMeshSceneNode::STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position,
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
#include <cstring> // for NULL
|
||||
|
@ -109,7 +109,7 @@ namespace GUIEngine
|
||||
*/
|
||||
void setImage(const char* path_to_texture,
|
||||
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/** Convenience function taking std::string. */
|
||||
void setImage(const std::string &path_to_texture,
|
||||
IconPathType path_type=ICON_PATH_TYPE_NO_CHANGE)
|
||||
@ -117,6 +117,7 @@ namespace GUIEngine
|
||||
setImage(path_to_texture.c_str(), path_type);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/**
|
||||
* Change the texture used for this icon.
|
||||
* \pre At the moment, the new texture must have the same aspct ratio
|
||||
@ -126,16 +127,22 @@ namespace GUIEngine
|
||||
*/
|
||||
void setImage(irr::video::ITexture* texture);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void setHighlightedImage(irr::video::ITexture* texture)
|
||||
{
|
||||
m_highlight_texture = texture;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/** \brief override from base class */
|
||||
virtual EventPropagation focused(const int playerID);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/** \brief override from base class */
|
||||
virtual void unfocused(const int playerID, Widget* new_focus);
|
||||
// --------------------------------------------------------------------
|
||||
/** Returns the texture of this button. */
|
||||
const video::ITexture* getTexture() const { return m_texture; }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST)
|
||||
m_sort_desc = false;
|
||||
m_sort_default = true;
|
||||
m_sort_col = 0;
|
||||
m_sortable = false;
|
||||
m_sortable = true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -723,7 +723,7 @@ void FileManager::checkAndCreateConfigDir()
|
||||
if(!checkAndCreateDirectory(m_user_config_dir))
|
||||
{
|
||||
Log::error("[FileManager]", "Can't create config dir '%s"
|
||||
", falling back to '.'.", m_user_config_dir);
|
||||
", falling back to '.'.", m_user_config_dir.c_str());
|
||||
m_user_config_dir = ".";
|
||||
}
|
||||
}
|
||||
|
@ -157,6 +157,10 @@ public:
|
||||
/** Returns true if this kart has no wheels. */
|
||||
bool isWheeless() const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the coordinates of the front of the kart. This is used for
|
||||
* determining when the lap line is crossed. */
|
||||
virtual const Vec3& getFrontXYZ() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the position of a wheel relative to the kart.
|
||||
* \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear
|
||||
* right, 3 = rear left. */
|
||||
|
@ -408,7 +408,8 @@ void Kart::reset()
|
||||
m_skidmarks->adjustFog(track->isFogEnabled() );
|
||||
}
|
||||
|
||||
m_terrain_info->update(getXYZ(), Vec3(0,-1,0));
|
||||
Vec3 front(0, 0, getKartLength()*0.5f);
|
||||
m_xyz_front = getTrans()(front);
|
||||
|
||||
|
||||
// Reset is also called when the kart is created, at which time
|
||||
@ -1201,6 +1202,9 @@ void Kart::update(float dt)
|
||||
m_body->getBroadphaseHandle()->m_collisionFilterGroup = 0;
|
||||
}
|
||||
|
||||
Vec3 front(0, 0, getKartLength()*0.5f);
|
||||
m_xyz_front = getTrans()(front);
|
||||
|
||||
|
||||
|
||||
m_terrain_info->update(getXYZ() + epsilon*(quadNormal), -quadNormal);
|
||||
|
@ -102,6 +102,10 @@ private:
|
||||
/** Current race position (1-num_karts). */
|
||||
int m_race_position;
|
||||
|
||||
/** The coordinates of the front of the kart, used to determine when a
|
||||
* new lap is triggered. */
|
||||
Vec3 m_xyz_front;
|
||||
|
||||
/** True if the kart is eliminated. */
|
||||
bool m_eliminated;
|
||||
|
||||
@ -292,6 +296,10 @@ public:
|
||||
/** Returns the current position of this kart in the race. */
|
||||
virtual int getPosition () const { return m_race_position; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the coordinates of the front of the kart. This is used for
|
||||
* determining when the lap line is crossed. */
|
||||
virtual const Vec3& getFrontXYZ() const { return m_xyz_front; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the initial position of this kart. */
|
||||
virtual int getInitialPosition () const { return m_initial_position; }
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -461,149 +461,149 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
} // if sounds-node exist
|
||||
|
||||
if(const XMLNode *nitro_node = root->getNode("nitro"))
|
||||
{
|
||||
nitro_node->get("consumption", &m_nitro_consumption );
|
||||
nitro_node->get("small-container", &m_nitro_small_container );
|
||||
nitro_node->get("big-container", &m_nitro_big_container );
|
||||
nitro_node->get("max-speed-increase", &m_nitro_max_speed_increase);
|
||||
nitro_node->get("engine-force", &m_nitro_engine_force );
|
||||
nitro_node->get("duration", &m_nitro_duration );
|
||||
nitro_node->get("fade-out-time", &m_nitro_fade_out_time );
|
||||
nitro_node->get("max", &m_nitro_max );
|
||||
nitro_node->get("min-consumption-time", &m_nitro_min_consumption );
|
||||
}
|
||||
|
||||
if(const XMLNode *bubble_node = root->getNode("bubblegum"))
|
||||
{
|
||||
bubble_node->get("time", &m_bubblegum_time );
|
||||
bubble_node->get("speed-fraction", &m_bubblegum_speed_fraction);
|
||||
bubble_node->get("fade-in-time", &m_bubblegum_fade_in_time );
|
||||
bubble_node->get("torque", &m_bubblegum_torque );
|
||||
}
|
||||
|
||||
if(const XMLNode *rescue_node = root->getNode("rescue"))
|
||||
{
|
||||
rescue_node->get("vert-offset", &m_rescue_vert_offset);
|
||||
rescue_node->get("time", &m_rescue_time );
|
||||
rescue_node->get("height", &m_rescue_height );
|
||||
}
|
||||
|
||||
if(const XMLNode *explosion_node = root->getNode("explosion"))
|
||||
{
|
||||
explosion_node->get("time", &m_explosion_time );
|
||||
explosion_node->get("radius", &m_explosion_radius);
|
||||
explosion_node->get("invulnerability-time",
|
||||
&m_explosion_invulnerability_time);
|
||||
}
|
||||
|
||||
if(const XMLNode *skid_node = root->getNode("skid"))
|
||||
{
|
||||
m_skidding_properties->load(skid_node);
|
||||
}
|
||||
|
||||
|
||||
if(const XMLNode *slipstream_node = root->getNode("slipstream"))
|
||||
{
|
||||
slipstream_node->get("length", &m_slipstream_length );
|
||||
slipstream_node->get("width", &m_slipstream_width );
|
||||
slipstream_node->get("collect-time", &m_slipstream_collect_time );
|
||||
slipstream_node->get("use-time", &m_slipstream_use_time );
|
||||
slipstream_node->get("add-power", &m_slipstream_add_power );
|
||||
slipstream_node->get("min-speed", &m_slipstream_min_speed );
|
||||
slipstream_node->get("max-speed-increase",
|
||||
&m_slipstream_max_speed_increase);
|
||||
slipstream_node->get("duration", &m_slipstream_duration );
|
||||
slipstream_node->get("fade-out-time",&m_slipstream_fade_out_time );
|
||||
}
|
||||
|
||||
if(const XMLNode *turn_node = root->getNode("turn"))
|
||||
{
|
||||
turn_node->get("time-full-steer", &m_time_full_steer );
|
||||
turn_node->get("time-reset-steer", &m_time_reset_steer );
|
||||
turn_node->get("turn-radius", &m_turn_angle_at_speed );
|
||||
// For now store the turn radius in turn angle, the correct
|
||||
// value can only be determined later in ::load
|
||||
}
|
||||
|
||||
if(const XMLNode *engine_node = root->getNode("engine"))
|
||||
{
|
||||
engine_node->get("brake-factor", &m_brake_factor);
|
||||
engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio);
|
||||
engine_node->get("power", &m_engine_power);
|
||||
if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
nitro_node->get("consumption", &m_nitro_consumption );
|
||||
nitro_node->get("small-container", &m_nitro_small_container );
|
||||
nitro_node->get("big-container", &m_nitro_big_container );
|
||||
nitro_node->get("max-speed-increase", &m_nitro_max_speed_increase);
|
||||
nitro_node->get("engine-force", &m_nitro_engine_force );
|
||||
nitro_node->get("duration", &m_nitro_duration );
|
||||
nitro_node->get("fade-out-time", &m_nitro_fade_out_time );
|
||||
nitro_node->get("max", &m_nitro_max );
|
||||
nitro_node->get("min-consumption-time", &m_nitro_min_consumption );
|
||||
Log::fatal("[KartProperties]",
|
||||
"Incorrect engine-power specifications for kart '%s'",
|
||||
getIdent().c_str());
|
||||
}
|
||||
|
||||
if(const XMLNode *bubble_node = root->getNode("bubblegum"))
|
||||
engine_node->get("max-speed", &m_max_speed);
|
||||
if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
bubble_node->get("time", &m_bubblegum_time );
|
||||
bubble_node->get("speed-fraction", &m_bubblegum_speed_fraction);
|
||||
bubble_node->get("fade-in-time", &m_bubblegum_fade_in_time );
|
||||
bubble_node->get("torque", &m_bubblegum_torque );
|
||||
Log::fatal("[KartProperties]",
|
||||
"Incorrect max-speed specifications for kart '%s'",
|
||||
getIdent().c_str());
|
||||
}
|
||||
} // if getNode("engine")
|
||||
|
||||
if(const XMLNode *rescue_node = root->getNode("rescue"))
|
||||
if(const XMLNode *gear_node = root->getNode("gear"))
|
||||
{
|
||||
gear_node->get("switch-ratio", &m_gear_switch_ratio );
|
||||
gear_node->get("power-increase", &m_gear_power_increase);
|
||||
}
|
||||
|
||||
if(const XMLNode *mass_node = root->getNode("mass"))
|
||||
mass_node->get("value", &m_mass);
|
||||
|
||||
if(const XMLNode *plunger_node= root->getNode("plunger"))
|
||||
{
|
||||
plunger_node->get("band-max-length", &m_rubber_band_max_length );
|
||||
plunger_node->get("band-force", &m_rubber_band_force );
|
||||
plunger_node->get("band-duration", &m_rubber_band_duration );
|
||||
plunger_node->get("band-speed-increase",&m_rubber_band_speed_increase);
|
||||
plunger_node->get("band-fade-out-time", &m_rubber_band_fade_out_time );
|
||||
plunger_node->get("in-face-time", &m_plunger_in_face_duration);
|
||||
if(m_plunger_in_face_duration.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
rescue_node->get("vert-offset", &m_rescue_vert_offset);
|
||||
rescue_node->get("time", &m_rescue_time );
|
||||
rescue_node->get("height", &m_rescue_height );
|
||||
Log::fatal("KartProperties",
|
||||
"Invalid plunger in-face-time specification.");
|
||||
}
|
||||
}
|
||||
|
||||
if(const XMLNode *explosion_node = root->getNode("explosion"))
|
||||
if(const XMLNode *zipper_node= root->getNode("zipper"))
|
||||
{
|
||||
zipper_node->get("time", &m_zipper_time );
|
||||
zipper_node->get("fade-out-time", &m_zipper_fade_out_time );
|
||||
zipper_node->get("force", &m_zipper_force );
|
||||
zipper_node->get("speed-gain", &m_zipper_speed_gain );
|
||||
zipper_node->get("max-speed-increase", &m_zipper_max_speed_increase);
|
||||
}
|
||||
|
||||
if(const XMLNode *swatter_node= root->getNode("swatter"))
|
||||
{
|
||||
swatter_node->get("duration", &m_swatter_duration );
|
||||
swatter_node->get("squash-duration", &m_squash_duration );
|
||||
swatter_node->get("squash-slowdown", &m_squash_slowdown );
|
||||
if(swatter_node->get("distance", &m_swatter_distance2) )
|
||||
{
|
||||
explosion_node->get("time", &m_explosion_time );
|
||||
explosion_node->get("radius", &m_explosion_radius);
|
||||
explosion_node->get("invulnerability-time",
|
||||
&m_explosion_invulnerability_time);
|
||||
// Avoid squaring if distance is not defined, so that
|
||||
// distance2 remains UNDEFINED (which is a negative value)
|
||||
m_swatter_distance2 *= m_swatter_distance2;
|
||||
}
|
||||
}
|
||||
|
||||
if(const XMLNode *skid_node = root->getNode("skid"))
|
||||
{
|
||||
m_skidding_properties->load(skid_node);
|
||||
}
|
||||
if(const XMLNode *lean_node= root->getNode("lean"))
|
||||
{
|
||||
lean_node->get("max", &m_max_lean );
|
||||
lean_node->get("speed", &m_lean_speed);
|
||||
m_max_lean *= DEGREE_TO_RAD;
|
||||
m_lean_speed *= DEGREE_TO_RAD;
|
||||
}
|
||||
|
||||
|
||||
if(const XMLNode *slipstream_node = root->getNode("slipstream"))
|
||||
{
|
||||
slipstream_node->get("length", &m_slipstream_length );
|
||||
slipstream_node->get("width", &m_slipstream_width );
|
||||
slipstream_node->get("collect-time", &m_slipstream_collect_time );
|
||||
slipstream_node->get("use-time", &m_slipstream_use_time );
|
||||
slipstream_node->get("add-power", &m_slipstream_add_power );
|
||||
slipstream_node->get("min-speed", &m_slipstream_min_speed );
|
||||
slipstream_node->get("max-speed-increase",
|
||||
&m_slipstream_max_speed_increase);
|
||||
slipstream_node->get("duration", &m_slipstream_duration );
|
||||
slipstream_node->get("fade-out-time",&m_slipstream_fade_out_time );
|
||||
}
|
||||
|
||||
if(const XMLNode *turn_node = root->getNode("turn"))
|
||||
{
|
||||
turn_node->get("time-full-steer", &m_time_full_steer );
|
||||
turn_node->get("time-reset-steer", &m_time_reset_steer );
|
||||
turn_node->get("turn-radius", &m_turn_angle_at_speed );
|
||||
// For now store the turn radius in turn angle, the correct
|
||||
// value can only be determined later in ::load
|
||||
}
|
||||
|
||||
if(const XMLNode *engine_node = root->getNode("engine"))
|
||||
{
|
||||
engine_node->get("brake-factor", &m_brake_factor);
|
||||
engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio);
|
||||
engine_node->get("power", &m_engine_power);
|
||||
if(m_engine_power.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
Log::fatal("[KartProperties]",
|
||||
"Incorrect engine-power specifications for kart '%s'",
|
||||
getIdent().c_str());
|
||||
}
|
||||
engine_node->get("max-speed", &m_max_speed);
|
||||
if(m_max_speed.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
Log::fatal("[KartProperties]",
|
||||
"Incorrect max-speed specifications for kart '%s'",
|
||||
getIdent().c_str());
|
||||
}
|
||||
} // if getNode("engine")
|
||||
|
||||
if(const XMLNode *gear_node = root->getNode("gear"))
|
||||
{
|
||||
gear_node->get("switch-ratio", &m_gear_switch_ratio );
|
||||
gear_node->get("power-increase", &m_gear_power_increase);
|
||||
}
|
||||
|
||||
if(const XMLNode *mass_node = root->getNode("mass"))
|
||||
mass_node->get("value", &m_mass);
|
||||
|
||||
if(const XMLNode *plunger_node= root->getNode("plunger"))
|
||||
{
|
||||
plunger_node->get("band-max-length", &m_rubber_band_max_length );
|
||||
plunger_node->get("band-force", &m_rubber_band_force );
|
||||
plunger_node->get("band-duration", &m_rubber_band_duration );
|
||||
plunger_node->get("band-speed-increase",&m_rubber_band_speed_increase);
|
||||
plunger_node->get("band-fade-out-time", &m_rubber_band_fade_out_time );
|
||||
plunger_node->get("in-face-time", &m_plunger_in_face_duration);
|
||||
if(m_plunger_in_face_duration.size()!=RaceManager::DIFFICULTY_COUNT)
|
||||
{
|
||||
Log::fatal("KartProperties",
|
||||
"Invalid plunger in-face-time specification.");
|
||||
}
|
||||
}
|
||||
|
||||
if(const XMLNode *zipper_node= root->getNode("zipper"))
|
||||
{
|
||||
zipper_node->get("time", &m_zipper_time );
|
||||
zipper_node->get("fade-out-time", &m_zipper_fade_out_time );
|
||||
zipper_node->get("force", &m_zipper_force );
|
||||
zipper_node->get("speed-gain", &m_zipper_speed_gain );
|
||||
zipper_node->get("max-speed-increase", &m_zipper_max_speed_increase);
|
||||
}
|
||||
|
||||
if(const XMLNode *swatter_node= root->getNode("swatter"))
|
||||
{
|
||||
swatter_node->get("duration", &m_swatter_duration );
|
||||
swatter_node->get("squash-duration", &m_squash_duration );
|
||||
swatter_node->get("squash-slowdown", &m_squash_slowdown );
|
||||
if(swatter_node->get("distance", &m_swatter_distance2) )
|
||||
{
|
||||
// Avoid squaring if distance is not defined, so that
|
||||
// distance2 remains UNDEFINED (which is a negative value)
|
||||
m_swatter_distance2 *= m_swatter_distance2;
|
||||
}
|
||||
}
|
||||
|
||||
if(const XMLNode *lean_node= root->getNode("lean"))
|
||||
{
|
||||
lean_node->get("max", &m_max_lean );
|
||||
lean_node->get("speed", &m_lean_speed);
|
||||
m_max_lean *= DEGREE_TO_RAD;
|
||||
m_lean_speed *= DEGREE_TO_RAD;
|
||||
}
|
||||
|
||||
if(const XMLNode *startup_node= root->getNode("startup"))
|
||||
{
|
||||
startup_node->get("time", &m_startup_times);
|
||||
startup_node->get("boost", &m_startup_boost);
|
||||
}
|
||||
if(const XMLNode *startup_node= root->getNode("startup"))
|
||||
{
|
||||
startup_node->get("time", &m_startup_times);
|
||||
startup_node->get("boost", &m_startup_boost);
|
||||
}
|
||||
|
||||
if(m_kart_model)
|
||||
m_kart_model->loadInfo(*root);
|
||||
|
@ -211,7 +211,7 @@ private:
|
||||
float m_nitro_small_container;
|
||||
/** Nitro amount for big bittle. */
|
||||
float m_nitro_big_container;
|
||||
/* How much the speed of a kart might exceed its maximum speed (in m/s). */
|
||||
/** How much the speed of a kart might exceed its maximum speed (in m/s). */
|
||||
float m_nitro_max_speed_increase;
|
||||
/** Additional engine force to affect the kart. */
|
||||
float m_nitro_engine_force;
|
||||
@ -250,7 +250,7 @@ private:
|
||||
/** The speed with which the roll (when leaning in a curve) changes
|
||||
* (in radians/second). */
|
||||
float m_lean_speed;
|
||||
|
||||
|
||||
/** How long a jump must be in order to trigger the jump animation. */
|
||||
float m_jump_animation_time;
|
||||
|
||||
@ -547,7 +547,7 @@ public:
|
||||
{
|
||||
return m_speed_weighted_object_properties;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the wheel base (distance front to rear axis). */
|
||||
float getWheelBase () const {return m_wheel_base; }
|
||||
|
@ -174,7 +174,7 @@ void LinearWorld::update(float dt)
|
||||
// rescued or eliminated
|
||||
if(kart->getKartAnimation()) continue;
|
||||
|
||||
kart_info.getTrackSector()->update(kart->getXYZ());
|
||||
kart_info.getTrackSector()->update(kart->getFrontXYZ());
|
||||
kart_info.m_overall_distance = kart_info.m_race_lap
|
||||
* m_track->getTrackLength()
|
||||
+ getDistanceDownTrackForKart(kart->getWorldKartId());
|
||||
|
@ -111,14 +111,15 @@ void GrandPrixData::changeTrackNumber(const unsigned int number_of_tracks,
|
||||
rand() % available_tracks :
|
||||
track_indices[rand() % available_tracks];
|
||||
|
||||
std::string id = track_manager->getTrack(index)->getIdent();
|
||||
const Track *track = track_manager->getTrack(index);
|
||||
std::string id = track->getIdent();
|
||||
// Avoid duplicate tracks
|
||||
if (std::find(m_tracks.begin(), m_tracks.end(), id) != m_tracks.end())
|
||||
continue;
|
||||
|
||||
m_tracks.push_back(id);
|
||||
m_laps.push_back(3); // TODO: Take the default number from the track
|
||||
m_reversed.push_back(false); // This will be changed later
|
||||
m_laps.push_back(track->getDefaultNumberOfLaps());
|
||||
m_reversed.push_back(false); // This will be changed later in the code
|
||||
}
|
||||
}
|
||||
else if (m_tracks.size() > number_of_tracks)
|
||||
|
@ -294,6 +294,13 @@ void AddonsLoading::onUpdate(float delta)
|
||||
const std::string icon = "icons/"+m_addon.getIconBasename();
|
||||
m_icon->setImage( file_manager->getAddonsFile(icon).c_str(),
|
||||
IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE );
|
||||
// Check if there was an error displaying the icon. If so, the icon
|
||||
// file is (likely) corrupt, and the file needs to be downloaded again.
|
||||
std::string s = m_icon->getTexture()->getName().getPath().c_str();
|
||||
if(StringUtils::getBasename(s)!=StringUtils::getBasename(icon))
|
||||
{
|
||||
m_addon.deleteInvalidIconFile();
|
||||
}
|
||||
m_icon_shown = true;
|
||||
}
|
||||
} // onUpdate
|
||||
|
@ -33,7 +33,6 @@ using irr::gui::IGUIStaticText;
|
||||
typedef GUIEngine::SpinnerWidget Spinner;
|
||||
|
||||
RandomGPInfoDialog::RandomGPInfoDialog()
|
||||
|
||||
{
|
||||
// Defaults - loading selection from last time frrom a file would be better
|
||||
m_number_of_tracks = 2; // We can assume that there are at least 2 standard tracks
|
||||
@ -88,13 +87,9 @@ void RandomGPInfoDialog::addSpinners()
|
||||
const std::vector<std::string>& groups = track_manager->getAllTrackGroups();
|
||||
for (unsigned int i = 0; i < groups.size(); i++)
|
||||
{
|
||||
// FIXME: The NULL check is necessary until #1348 on github is fixed
|
||||
if (groups[i].c_str() != NULL)
|
||||
{
|
||||
spinner->addLabel(stringw(groups[i].c_str()));
|
||||
if(groups[i] == "standard")
|
||||
index_standard = i+1;
|
||||
}
|
||||
spinner->addLabel(stringw(groups[i].c_str()));
|
||||
if(groups[i] == "standard")
|
||||
index_standard = i+1;
|
||||
}
|
||||
// The value can only be set here because SpinnerWidget resets the value
|
||||
// every time a label is added
|
||||
|
@ -88,9 +88,7 @@ TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::strin
|
||||
screenshotWidget->add();
|
||||
|
||||
if (screenshot != NULL)
|
||||
{
|
||||
screenshotWidget->setImage(screenshot);
|
||||
}
|
||||
m_widgets.push_back(screenshotWidget);
|
||||
|
||||
|
||||
@ -98,21 +96,11 @@ TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::strin
|
||||
if (has_laps)
|
||||
{
|
||||
m_spinner = getWidget<SpinnerWidget>("lapcountspinner");
|
||||
|
||||
m_spinner->m_properties[PROP_ID] = "lapcountspinner";
|
||||
if (UserConfigParams::m_artist_debug_mode)
|
||||
{
|
||||
m_spinner->setMin(0);
|
||||
}
|
||||
|
||||
//I18N: In the track setup screen (number of laps choice, where %i is the number)
|
||||
//m_spinner->setText( _("%i laps") );
|
||||
m_spinner->setValue( UserConfigParams::m_num_laps );
|
||||
//m_spinner->getIrrlichtElement()->setTabStop(true);
|
||||
//m_spinner->getIrrlichtElement()->setTabGroup(false);
|
||||
|
||||
const int num_laps = m_spinner->getValue();
|
||||
race_manager->setNumLaps(num_laps);
|
||||
m_spinner->setValue(track->getDefaultNumberOfLaps());
|
||||
race_manager->setNumLaps(m_spinner->getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -149,7 +137,6 @@ TrackInfoDialog::TrackInfoDialog(const std::string& ribbonItem, const std::strin
|
||||
m_highscore_entries[2] = getWidget<LabelWidget>("highscore3");
|
||||
|
||||
updateHighScores();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ void CheckStructure::update(float dt)
|
||||
World *world = World::getWorld();
|
||||
for(unsigned int i=0; i<world->getNumKarts(); i++)
|
||||
{
|
||||
const Vec3 &xyz = world->getKart(i)->getXYZ();
|
||||
const Vec3 &xyz = world->getKart(i)->getFrontXYZ();
|
||||
if(world->getKart(i)->getKartAnimation()) continue;
|
||||
// Only check active checklines.
|
||||
if(m_is_active[i] && isTriggered(m_previous_position[i], xyz, i))
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "matrix4.h"
|
||||
#include "tracks/quad_graph.hpp"
|
||||
#include "tracks/quad_set.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Constructor. Saves the quad index which belongs to this graph node.
|
||||
|
@ -135,6 +135,7 @@ Track::Track(const std::string &filename)
|
||||
m_ident=="overworld";
|
||||
m_minimap_x_scale = 1.0f;
|
||||
m_minimap_y_scale = 1.0f;
|
||||
m_default_number_of_laps= 3;
|
||||
m_all_nodes.clear();
|
||||
m_all_physics_only_nodes.clear();
|
||||
m_all_cached_meshes.clear();
|
||||
@ -471,6 +472,7 @@ void Track::loadTrackInfo()
|
||||
root->get("groups", &m_groups);
|
||||
root->get("internal", &m_internal);
|
||||
root->get("reverse", &m_reverse_available);
|
||||
root->get("default-number-of-laps",&m_default_number_of_laps);
|
||||
root->get("push-back", &m_enable_push_back);
|
||||
root->get("clouds", &m_clouds);
|
||||
root->get("bloom", &m_bloom);
|
||||
|
@ -206,7 +206,7 @@ private:
|
||||
/** True if this track (textures and track data) should be cached. Used
|
||||
* for the overworld. */
|
||||
bool m_cache_track;
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
/** A list of textures that were cached before the track is loaded.
|
||||
@ -388,7 +388,7 @@ private:
|
||||
|
||||
float m_displacement_speed;
|
||||
float m_caustics_speed;
|
||||
|
||||
|
||||
/** The levels for color correction
|
||||
* m_color_inlevel(black, gamma, white)
|
||||
* m_color_outlevel(black, white)*/
|
||||
@ -398,6 +398,9 @@ private:
|
||||
/** List of all bezier curves in the track - for e.g. camera, ... */
|
||||
std::vector<BezierCurve*> m_all_curves;
|
||||
|
||||
/** The number of laps the track will be raced if no other value is given.*/
|
||||
int m_default_number_of_laps;
|
||||
|
||||
void loadTrackInfo();
|
||||
void loadQuadGraph(unsigned int mode_id, const bool reverse);
|
||||
void convertTrackToBullet(scene::ISceneNode *node);
|
||||
@ -599,7 +602,7 @@ public:
|
||||
|
||||
bool getBloom() const { return m_bloom; }
|
||||
float getBloomThreshold() const { return m_bloom_threshold; }
|
||||
|
||||
|
||||
/** Return the color levels for color correction shader */
|
||||
core::vector3df getColorLevelIn() const { return m_color_inlevel; }
|
||||
core::vector2df getColorLevelOut() const { return m_color_outlevel; }
|
||||
@ -607,11 +610,12 @@ public:
|
||||
bool hasLensFlare() const { return m_lensflare; }
|
||||
bool hasGodRays() const { return m_godrays; }
|
||||
bool hasShadows() const { return m_shadows; }
|
||||
|
||||
|
||||
void addNode(scene::ISceneNode* node) { m_all_nodes.push_back(node); }
|
||||
|
||||
float getDisplacementSpeed() const { return m_displacement_speed; }
|
||||
float getCausticsSpeed() const { return m_caustics_speed; }
|
||||
const int getDefaultNumberOfLaps() const { return m_default_number_of_laps;}
|
||||
bool operator<(const Track &other) const;
|
||||
}; // class Track
|
||||
|
||||
|
@ -243,9 +243,9 @@ TrackObject::~TrackObject()
|
||||
*/
|
||||
void TrackObject::reset()
|
||||
{
|
||||
if (m_presentation != NULL) m_presentation->reset();
|
||||
|
||||
if (m_animator != NULL) m_animator->reset();
|
||||
if (m_presentation ) m_presentation->reset();
|
||||
if (m_animator ) m_animator->reset();
|
||||
if(m_physical_object) m_physical_object->reset();
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -24,7 +24,7 @@
|
||||
// btAlignedObjectArray to enable bullet SSE optimisations.
|
||||
// On the other hand, std::vector gives much better debugging features.
|
||||
// So SSE is disabled in bullet on windows debug
|
||||
#if !defined(DEBUG) && (WIN32)
|
||||
#if !defined(DEBUG) && defined(WIN32)
|
||||
# undef USE_ALIGNED
|
||||
#else
|
||||
# undef USE_ALIGNED
|
||||
|
92
src/utils/tuple.hpp
Normal file
92
src/utils/tuple.hpp
Normal file
@ -0,0 +1,92 @@
|
||||
#ifndef __STK_TUPLE_HPP__
|
||||
#define __STK_TUPLE_HPP__
|
||||
|
||||
namespace STK {
|
||||
|
||||
|
||||
// tuple
|
||||
template<typename... _Types> class Tuple;
|
||||
|
||||
// empty tuple
|
||||
template<> class Tuple<> {};
|
||||
|
||||
// recursive tuple definition
|
||||
template<typename _This, typename... _Rest>
|
||||
class Tuple<_This, _Rest...> : private Tuple<_Rest...>
|
||||
{
|
||||
public:
|
||||
_This _Elem;
|
||||
|
||||
Tuple()
|
||||
{
|
||||
}
|
||||
|
||||
Tuple(_This val, _Rest... rest) : Tuple<_Rest...>(rest...)
|
||||
{
|
||||
_Elem = val;
|
||||
}
|
||||
};
|
||||
|
||||
// tuple_element
|
||||
template<size_t _Index, typename _Tuple> struct tuple_element;
|
||||
|
||||
// select first element
|
||||
template<typename _This, typename... _Rest>
|
||||
struct tuple_element<0, Tuple<_This, _Rest...>>
|
||||
{
|
||||
typedef _This& type;
|
||||
typedef Tuple<_This, _Rest...> _Ttype;
|
||||
};
|
||||
|
||||
// recursive tuple_element definition
|
||||
template <size_t _Index, typename _This, typename... _Rest>
|
||||
struct tuple_element<_Index, Tuple<_This, _Rest...>>
|
||||
: public tuple_element<_Index - 1, Tuple<_Rest...> >
|
||||
{
|
||||
};
|
||||
|
||||
template<size_t _Index, class... _Types> inline
|
||||
typename tuple_element<_Index, Tuple<_Types...>>::type
|
||||
tuple_get(Tuple<_Types...>& _Tuple)
|
||||
{
|
||||
typedef typename tuple_element<_Index, Tuple<_Types...>>::_Ttype _Ttype;
|
||||
return (((_Ttype&)_Tuple)._Elem);
|
||||
}
|
||||
|
||||
template<size_t _Index, class... _Types> inline
|
||||
typename tuple_element<_Index, Tuple<_Types...>>::type tuple_get(const Tuple<_Types...>& _Tuple)
|
||||
{
|
||||
typedef typename tuple_element<_Index, Tuple<_Types...>>::_Ttype _Ttype;
|
||||
return (((_Ttype&)_Tuple)._Elem);
|
||||
}
|
||||
|
||||
template<size_t Index, typename... T> inline
|
||||
Tuple<T...> make_tuple(T... values)
|
||||
{
|
||||
return Tuple<T...>(values...);
|
||||
}
|
||||
|
||||
template<typename... T> inline
|
||||
Tuple<T...> make_tuple(T... values)
|
||||
{
|
||||
return Tuple<T...>(values...);
|
||||
}
|
||||
|
||||
//template<typename... T>
|
||||
//int tuple_size(Tuple<T...> tuple)
|
||||
//{
|
||||
// return sizeof...(T);
|
||||
//}
|
||||
|
||||
template<typename... T>
|
||||
struct TupleSize
|
||||
{
|
||||
int value;
|
||||
TupleSize()
|
||||
{
|
||||
value = sizeof...(T);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -3,7 +3,7 @@
|
||||
* so we define the work arounds only for compiler versions before 18.00
|
||||
*/
|
||||
|
||||
#if defined(WIN32) && _MSC_VER < 1800
|
||||
#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1800
|
||||
# include <math.h>
|
||||
|
||||
# define isnan _isnan
|
||||
|
Loading…
Reference in New Issue
Block a user