Merge remote-tracking branch 'origin/NewRTTMinimap'

This commit is contained in:
vlj 2014-07-02 00:24:03 +02:00
commit 475d738d4b
20 changed files with 211 additions and 100 deletions

View File

@ -4,6 +4,7 @@ uniform sampler2D tex;
uniform sampler2D logluminancetex;
uniform float exposure = .09;
uniform float Lwhite = 1.;
uniform float vignette_weight = 0.;
layout (std140) uniform MatrixesData
{
@ -43,12 +44,11 @@ void main()
// Uncharted2 tonemap with Auria's custom coefficients
vec4 perChannel = (col * (6.9 * col + .5)) / (col * (5.2 * col + 1.7) + 0.06);
perChannel = pow(perChannel, vec4(2.2));
vec2 inside = uv - 0.5;
float vignette = 1 - dot(inside, inside);
float vignette = 1. - dot(inside, inside) * vignette_weight;
vignette = clamp(pow(vignette, 0.8), 0., 1.);
//vignette = clamp(vignette + vignette - 0.5, 0., 1.15);
FragColor = vec4(perChannel.xyz * vignette, col.a);
}

View File

@ -12,5 +12,5 @@ varying vec2 uv;
void main()
{
vec4 res = texture(tex, uv);
FragColor = vec4(res.xyz * color.xyz / 255., res.a);
FragColor = res * color / 255.;
}

View File

@ -780,9 +780,13 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
bool useAlphaChannelOfTexture)
const video::SColor &colors, bool useAlphaChannelOfTexture)
{
glEnable(GL_BLEND);
if (useAlphaChannelOfTexture)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
float width, height,
center_pos_x, center_pos_y,
tex_width, tex_height,
@ -791,9 +795,16 @@ void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
getSize(texture_w, texture_h, true,
destRect, sourceRect, width, height, center_pos_x, center_pos_y,
tex_width, tex_height, tex_center_pos_x, tex_center_pos_y);
drawTexQuad(texture, width, height, center_pos_x, center_pos_y,
tex_center_pos_x, tex_center_pos_y, tex_width, tex_height);
glUseProgram(UIShader::UniformColoredTextureRectShader::Program);
glBindVertexArray(UIShader::UniformColoredTextureRectShader::vao);
setTexture(0, texture, GL_LINEAR, GL_LINEAR);
UIShader::UniformColoredTextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, colors, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,

View File

@ -214,7 +214,7 @@ public:
FrameBuffer(const std::vector <GLuint> &RTTs, GLuint DS, size_t w, size_t h, bool layered = false);
~FrameBuffer();
void Bind();
std::vector<GLuint> &getRTT() { return RenderTargets; }
const std::vector<GLuint> &getRTT() const { return RenderTargets; }
GLuint &getDepthTexture() { assert(DepthTexture); return DepthTexture; }
size_t getWidth() const { return width; }
size_t getHeight() const { return height; }
@ -239,7 +239,7 @@ void draw3DLine(const core::vector3df& start,
void draw2DImageFromRTT(GLuint texture, size_t texture_w, size_t texture_h,
const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
bool useAlphaChannelOfTexture);
const video::SColor &colors, bool useAlphaChannelOfTexture);
void draw2DImage(const irr::video::ITexture* texture, const irr::core::rect<s32>& destRect,
const irr::core::rect<s32>& sourceRect, const irr::core::rect<s32>* clipRect,

View File

@ -2055,7 +2055,10 @@ bool IrrDriver::supportsSplatting()
#endif
// ----------------------------------------------------------------------------
/** Begins a rendering to a texture.
/**
* THIS IS THE OLD OPENGL 1 RTT PROVIDER, USE THE SHADER-BASED
* RTT FOR NEW DEVELOPMENT
* Begins a rendering to a texture.
* \param dimension The size of the texture.
* \param name Name of the texture.
* \param persistent_texture Whether the created RTT texture should persist in

View File

@ -716,8 +716,11 @@ public:
unsigned UpdateLightsInfo(scene::ICameraSceneNode * const camnode, float dt);
void computeCameraMatrix(scene::ICameraSceneNode * const camnode, size_t width, size_t height);
// --------------------- RTT --------------------
// --------------------- OLD RTT --------------------
/**
* THIS IS THE OLD OPENGL 1 RTT PROVIDER, USE THE SHADER-BASED
* RTT FOR NEW DEVELOPMENT
*
* Class that provides RTT (currently, only when no other 3D rendering
* in the main scene is required)
* Provides an optional 'setupRTTScene' method to make it quick and easy

View File

@ -727,7 +727,7 @@ void PostProcessing::applyMLAA()
// ----------------------------------------------------------------------------
/** Render the post-processed scene */
FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode)
FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, bool isRace)
{
IVideoDriver * const drv = irr_driver->getVideoDriver();
@ -745,7 +745,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode)
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
if (UserConfigParams::m_dof)
if (isRace && UserConfigParams::m_dof)
{
PROFILER_PUSH_CPU_MARKER("- DoF", 0xFF, 0x00, 0x00);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_DOF));
@ -761,7 +761,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode)
if (World::getWorld() != NULL)
hasgodrays = World::getWorld()->getTrack()->hasGodRays();
if (UserConfigParams::m_light_shaft && m_sunpixels > 30 && hasgodrays)
if (isRace && UserConfigParams::m_light_shaft && m_sunpixels > 30 && hasgodrays)
{
glEnable(GL_DEPTH_TEST);
// Grab the sky
@ -827,7 +827,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode)
{
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_BLOOM));
if (UserConfigParams::m_bloom)
if (isRace && UserConfigParams::m_bloom)
{
glClear(GL_STENCIL_BUFFER_BIT);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
@ -879,7 +879,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode)
{
PROFILER_PUSH_CPU_MARKER("- Motion blur", 0xFF, 0x00, 0x00);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_MOTIONBLUR));
if (UserConfigParams::m_motionblur && m_any_boost && World::getWorld() != NULL) // motion blur
if (isRace && UserConfigParams::m_motionblur && m_any_boost && World::getWorld() != NULL) // motion blur
{
renderMotionBlur(0, *in_fbo, *out_fbo);
std::swap(in_fbo, out_fbo);

View File

@ -97,7 +97,7 @@ public:
void renderGlow(unsigned tex);
/** Render the post-processed scene */
FrameBuffer *render(scene::ICameraSceneNode * const camnode);
FrameBuffer *render(scene::ICameraSceneNode * const camnode, bool isRace);
/** Use motion blur for a short time */
void giveBoost(unsigned int cam_index);

View File

@ -186,7 +186,7 @@ void IrrDriver::renderGLSL(float dt)
// Render the post-processed scene
if (UserConfigParams::m_dynamic_lights)
{
FrameBuffer *fbo = m_post_processing->render(camnode);
FrameBuffer *fbo = m_post_processing->render(camnode, true);
if (irr_driver->getNormals())
irr_driver->getFBO(FBO_NORMAL_AND_DEPTHS).BlitToDefault(viewport.UpperLeftCorner.X, viewport.UpperLeftCorner.Y, viewport.LowerRightCorner.X, viewport.LowerRightCorner.Y);
@ -837,13 +837,17 @@ void IrrDriver::computeCameraMatrix(scene::ICameraSceneNode * const camnode, siz
{
core::aabbox3df trackbox(vmin->toIrrVector(), vmax->toIrrVector() -
core::vector3df(0, 30, 0));
SunCamViewMatrix.transformBoxEx(trackbox);
core::matrix4 tmp_matrix;
tmp_matrix.buildProjectionMatrixOrthoLH(trackbox.MinEdge.X, trackbox.MaxEdge.X,
trackbox.MaxEdge.Y, trackbox.MinEdge.Y,
30, trackbox.MaxEdge.Z);
m_suncam->setProjectionMatrix(tmp_matrix, true);
m_suncam->render();
if (trackbox.MinEdge.X != trackbox.MaxEdge.X &&
trackbox.MinEdge.Y != trackbox.MaxEdge.Y)
{
SunCamViewMatrix.transformBoxEx(trackbox);
core::matrix4 tmp_matrix;
tmp_matrix.buildProjectionMatrixOrthoLH(trackbox.MinEdge.X, trackbox.MaxEdge.X,
trackbox.MaxEdge.Y, trackbox.MinEdge.Y,
30, trackbox.MaxEdge.Z);
m_suncam->setProjectionMatrix(tmp_matrix, true);
m_suncam->render();
}
rsm_matrix = getVideoDriver()->getTransform(video::ETS_PROJECTION) * getVideoDriver()->getTransform(video::ETS_VIEW);
}
rh_extend = core::vector3df(128, 64, 128);

View File

@ -20,7 +20,9 @@
#include "config/user_config.hpp"
#include "graphics/glwrap.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/post_processing.hpp"
#include "utils/log.hpp"
#include <ISceneManager.h>
static GLuint generateRTT3D(GLenum target, size_t w, size_t h, size_t d, GLint internalFormat, GLint format, GLint type)
{
@ -72,6 +74,8 @@ static GLuint generateFBO(GLuint ColorAttachement, GLuint DepthAttachement)
RTT::RTT(size_t width, size_t height)
{
m_width = width;
m_height = height;
m_shadow_FBO = NULL;
m_RH_FBO = NULL;
m_RSM = NULL;
@ -281,3 +285,24 @@ RTT::~RTT()
glDeleteTextures(1, &RH_Blue);
}
}
FrameBuffer* RTT::render(scene::ICameraSceneNode* camera, float dt)
{
irr_driver->setRTT(this);
irr_driver->getSceneManager()->setActiveCamera(camera);
std::vector<IrrDriver::GlowData> glows;
irr_driver->computeCameraMatrix(camera, m_width, m_height);
unsigned plc = irr_driver->UpdateLightsInfo(camera, dt);
irr_driver->renderScene(camera, plc, glows, dt, false, true);
FrameBuffer* frame_buffer = irr_driver->getPostProcessing()->render(camera, false);
// reset
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
irr_driver->setRTT(NULL);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
irr_driver->getSceneManager()->setActiveCamera(NULL);
return frame_buffer;
}

View File

@ -45,11 +45,17 @@ public:
unsigned getDepthStencilTexture() const { return DepthStencilTexture; }
unsigned getRenderTarget(enum TypeRTT target) const { return RenderTargetTextures[target]; }
FrameBuffer& getFBO(enum TypeFBO fbo) { return FrameBuffers[fbo]; }
FrameBuffer* render(scene::ICameraSceneNode* camera, float dt);
private:
unsigned RenderTargetTextures[RTT_COUNT];
PtrVector<FrameBuffer> FrameBuffers;
unsigned DepthStencilTexture;
int m_width;
int m_height;
unsigned shadowColorTex, shadowNormalTex, shadowDepthTex;
unsigned RSM_Color, RSM_Normal, RSM_Depth;
unsigned RH_Red, RH_Green, RH_Blue;

View File

@ -1944,7 +1944,7 @@ void Skin::process3DPane(IGUIElement *element, const core::recti &rect,
if (fb != NULL && fb->getRTT().size() > 0)
{
draw2DImageFromRTT(fb->getRTT()[0], 512, 512,
rect, core::rect<s32>(0, 0, 512, 512), NULL, true);
rect, core::rect<s32>(0, 0, 512, 512), NULL, SColor(255, 255, 255, 255), true);
}
}
else if (type == WTYPE_ICON_BUTTON || type == WTYPE_MODEL_VIEW)

View File

@ -173,21 +173,9 @@ void ModelViewWidget::update(float delta)
m_rtt_main_node->setRotation(core::vector3df(0.0f, angle, 0.0f));
m_rtt_main_node->setVisible(true);
irr_driver->setRTT(m_rtt_provider);
irr_driver->getSceneManager()->setActiveCamera(m_camera);
m_frame_buffer = m_rtt_provider->render(m_camera, GUIEngine::getLatestDt());
std::vector<IrrDriver::GlowData> glows;
irr_driver->computeCameraMatrix(m_camera, 512, 512);
unsigned plc = irr_driver->UpdateLightsInfo(m_camera, GUIEngine::getLatestDt());
irr_driver->renderScene(m_camera, plc, glows, GUIEngine::getLatestDt(), false, true);
m_frame_buffer = irr_driver->getPostProcessing()->render(m_camera);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
irr_driver->setRTT(NULL);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
irr_driver->getSceneManager()->setActiveCamera(NULL);
m_rtt_main_node->setVisible(false);
}
@ -284,10 +272,7 @@ void ModelViewWidget::setupRTTScene(PtrVector<scene::IMesh, REF>& mesh,
m_camera->setAspectRatio(1.0f);
m_camera->setPosition(core::vector3df(0.0, 20.0f, 70.0f));
if (irr_driver->isGLSL())
m_camera->setUpVector(core::vector3df(0.0, 1.0, 0.0));
else
m_camera->setUpVector(core::vector3df(0.0, 1.0, 0.0));
m_camera->setUpVector(core::vector3df(0.0, 1.0, 0.0));
m_camera->setTarget(core::vector3df(0, 10, 0.0f));
m_camera->setFOV(DEGREE_TO_RAD*50.0f);
m_camera->updateAbsolutePosition();

View File

@ -342,19 +342,28 @@ void RaceGUI::drawGlobalMiniMap()
// arenas currently don't have a map.
if(world->getTrack()->isArena() || world->getTrack()->isSoccer()) return;
const video::ITexture *mini_map = world->getTrack()->getMiniMap();
const video::ITexture *old_rtt_mini_map = world->getTrack()->getOldRttMiniMap();
const FrameBuffer* new_rtt_mini_map = world->getTrack()->getNewRttMiniMap();
int upper_y = UserConfigParams::m_height - m_map_bottom - m_map_height;
int lower_y = UserConfigParams::m_height - m_map_bottom;
if (mini_map != NULL)
core::rect<s32> dest(m_map_left, upper_y,
m_map_left + m_map_width, lower_y);
if (old_rtt_mini_map != NULL)
{
core::rect<s32> dest(m_map_left, upper_y,
m_map_left + m_map_width, lower_y);
core::rect<s32> source(core::position2di(0, 0),
mini_map->getOriginalSize());
draw2DImage(mini_map, dest, source,
NULL, NULL, true);
old_rtt_mini_map->getOriginalSize());
draw2DImage(old_rtt_mini_map, dest, source,
NULL, NULL, true);
}
else if (new_rtt_mini_map != NULL)
{
core::rect<s32> source(0, 0, new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight());
draw2DImageFromRTT(new_rtt_mini_map->getRTT()[0],
new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight(),
dest, source, NULL, video::SColor(127, 255, 255, 255), true);
}
for(unsigned int i=0; i<world->getNumKarts(); i++)

View File

@ -321,17 +321,26 @@ void RaceGUIOverworld::drawGlobalMiniMap()
}
const video::ITexture *mini_map = world->getTrack()->getMiniMap();
const video::ITexture *old_rtt_mini_map = world->getTrack()->getOldRttMiniMap();
const FrameBuffer* new_rtt_mini_map = world->getTrack()->getNewRttMiniMap();
int upper_y = m_map_bottom - m_map_height;
int lower_y = m_map_bottom;
if (mini_map != NULL)
core::rect<s32> dest(m_map_left, upper_y,
m_map_left + m_map_width, lower_y);
if (old_rtt_mini_map != NULL)
{
core::rect<s32> dest(m_map_left, upper_y,
m_map_left + m_map_width, lower_y);
core::rect<s32> source(core::position2di(0, 0), mini_map->getOriginalSize());
draw2DImage(mini_map, dest, source, 0, 0, true);
core::rect<s32> source(core::position2di(0, 0), old_rtt_mini_map->getOriginalSize());
draw2DImage(old_rtt_mini_map, dest, source, 0, 0, true);
}
else if (new_rtt_mini_map != NULL)
{
core::rect<s32> source(0, 0, new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight());
draw2DImageFromRTT(new_rtt_mini_map->getRTT()[0],
new_rtt_mini_map->getWidth(), new_rtt_mini_map->getHeight(),
dest, source, NULL, video::SColor(127, 255, 255, 255), true);
}
Vec3 kart_xyz;

View File

@ -452,12 +452,12 @@ void QuadGraph::createMesh(bool show_invisible,
// Set up the indices for the triangles
// (note, afaik with opengl we could use quads directly, but the code
// would not be portable to directx anymore).
ind[6*i ] = 4*i; // First triangle: vertex 0, 1, 2
ind[6*i ] = 4*i+2; // First triangle: vertex 0, 1, 2
ind[6*i+1] = 4*i+1;
ind[6*i+2] = 4*i+2;
ind[6*i+3] = 4*i; // second triangle: vertex 0, 1, 3
ind[6*i+2] = 4*i;
ind[6*i+3] = 4*i+3; // second triangle: vertex 0, 1, 3
ind[6*i+4] = 4*i+2;
ind[6*i+5] = 4*i+3;
ind[6*i+5] = 4*i;
i++;
} // for i=1; i<QuadSet::get()
@ -491,12 +491,12 @@ void QuadGraph::createMesh(bool show_invisible,
lap_v[2].Pos = lap_v[1].Pos+core::vector3df(0, 0, 1);
else
lap_v[2].Pos = lap_v[1].Pos+dr*length/sqrt(lr2);
lap_ind[0] = 0;
lap_ind[0] = 2;
lap_ind[1] = 1;
lap_ind[2] = 2;
lap_ind[3] = 0;
lap_ind[2] = 0;
lap_ind[3] = 3;
lap_ind[4] = 2;
lap_ind[5] = 3;
lap_ind[5] = 0;
// Set it a bit higher to avoid issued with z fighting,
// i.e. part of the lap line might not be visible.
for(unsigned int i=0; i<4; i++)
@ -970,20 +970,37 @@ int QuadGraph::findOutOfRoadSector(const Vec3& xyz,
//-----------------------------------------------------------------------------
/** Takes a snapshot of the driveline quads so they can be used as minimap.
*/
video::ITexture *QuadGraph::makeMiniMap(const core::dimension2du &origdimension,
const std::string &name,
const video::SColor &fill_color)
void QuadGraph::makeMiniMap(const core::dimension2du &dimension,
const std::string &name,
const video::SColor &fill_color,
video::ITexture** oldRttMinimap,
FrameBuffer** newRttMinimap)
{
const core::dimension2du dimension = origdimension * 2;
const SColor oldClearColor = World::getWorld()->getClearColor();
World::getWorld()->setClearbackBufferColor(SColor(0, 255, 255, 255));
*oldRttMinimap = NULL;
*newRttMinimap = NULL;
RTT* newRttProvider = NULL;
IrrDriver::RTTProvider* oldRttProvider = NULL;
if (irr_driver->isGLSL())
{
newRttProvider = new RTT(dimension.Width, dimension.Height);
}
else
{
oldRttProvider = new IrrDriver::RTTProvider(dimension, name, true);
}
irr_driver->getSceneManager()->setAmbientLight(video::SColor(255, 255, 255, 255));
IrrDriver::RTTProvider rttProvider(dimension, name, true);
video::SColor red(128, 255, 0, 0);
createMesh(/*show_invisible part of the track*/ false,
/*enable_transparency*/ false,
/*track_color*/ &fill_color,
/*lap line color*/ &red );
m_node = irr_driver->getSceneManager()->addMeshSceneNode(m_mesh); // add Debug Mesh
m_node = irr_driver->addMesh(m_mesh);
#ifdef DEBUG
m_node->setName("minimap-mesh");
#endif
@ -1031,32 +1048,54 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2du &origdimension,
float range = (dx>dz) ? dx : dz;
core::matrix4 projection;
projection.buildProjectionMatrixOrthoLH(range,
range,
projection.buildProjectionMatrixOrthoLH(range /* width */,
range /* height */,
-1, bb_max.getY()-bb_min.getY()+1);
camera->setProjectionMatrix(projection, true);
irr_driver->suppressSkyBox();
irr_driver->clearLights();
// Adjust Y position by +1 for max, -1 for min - this helps in case that
// the maximum Y coordinate is negative (otherwise the minimap is mirrored)
// and avoids problems for tracks which have a flat (max Y = min Y) minimap.
camera->setPosition(core::vector3df(center.getX(), bb_max.getY()+1, center.getZ()));
camera->setPosition(core::vector3df(center.getX(), bb_min.getY() + 1.0f, center.getZ()));
//camera->setPosition(core::vector3df(center.getX() - 5.0f, bb_min.getY() - 1 - 5.0f, center.getZ() - 15.0f));
camera->setUpVector(core::vector3df(0, 0, 1));
camera->setTarget(core::vector3df(center.getX(),bb_min.getY()-1,center.getZ()));
//camera->setAspectRatio(1.0f);
camera->updateAbsolutePosition();
video::ITexture *texture = rttProvider.renderToTexture();
video::ITexture* texture = NULL;
FrameBuffer* frame_buffer = NULL;
if (irr_driver->isGLSL())
{
frame_buffer = newRttProvider->render(camera, GUIEngine::getLatestDt());
// TODO: leak
//delete newRttProvider;
}
else
{
texture = oldRttProvider->renderToTexture();
delete oldRttProvider;
}
cleanupDebugMesh();
irr_driver->removeCameraSceneNode(camera);
m_min_coord = bb_min;
if (texture == NULL)
if (texture == NULL && frame_buffer == NULL)
{
Log::error("Quad Graph", "[makeMiniMap] WARNING: RTT does not appear to work,"
"mini-map will not be available.");
return NULL;
}
return texture;
*oldRttMinimap = texture;
*newRttMinimap = frame_buffer;
World::getWorld()->setClearbackBufferColor(oldClearColor);
} // makeMiniMap
//-----------------------------------------------------------------------------

View File

@ -37,6 +37,7 @@ namespace irr
using namespace irr;
class CheckLine;
class FrameBuffer;
/**
* \brief This class stores a graph of quads. It uses a 'simplified singleton'
@ -118,10 +119,11 @@ public:
float forwards_distance=1.5f,
float sidewards_distance=1.5f,
float upwards_distance=0.0f) const;
video::ITexture *makeMiniMap(const core::dimension2du &where,
const std::string &name,
const video::SColor &fill_color
=video::SColor(127, 255, 255, 255) );
void makeMiniMap(const core::dimension2du &where,
const std::string &name,
const video::SColor &fill_color,
video::ITexture** oldRttMinimap,
FrameBuffer** newRttMinimap);
void mapPoint2MiniMap(const Vec3 &xyz, Vec3 *out) const;
void updateDistancesForAllSuccessors(unsigned int indx,
float delta,

View File

@ -115,7 +115,8 @@ Track::Track(const std::string &filename)
m_is_soccer = false;
m_is_cutscene = false;
m_camera_far = 1000.0f;
m_mini_map = NULL;
m_old_rtt_mini_map = NULL;
m_new_rtt_mini_map = NULL;
m_bloom = true;
m_bloom_threshold = 0.75f;
m_color_inlevel = core::vector3df(0.0,1.0, 255.0);
@ -273,13 +274,13 @@ void Track::cleanup()
// Clear reminder of the link between textures and file names.
irr_driver->clearTexturesFileName();
for(unsigned int i=0; i<m_animated_textures.size(); i++)
for (unsigned int i = 0; i < m_animated_textures.size(); i++)
{
delete m_animated_textures[i];
}
m_animated_textures.clear();
for(unsigned int i=0; i<m_all_nodes.size(); i++)
for (unsigned int i = 0; i < m_all_nodes.size(); i++)
{
irr_driver->removeNode(m_all_nodes[i]);
}
@ -310,37 +311,42 @@ void Track::cleanup()
// than once are in m_all_cached_mesh more than once (which is easier
// than storing the mesh only once, but then having to test for each
// mesh if it is already contained in the list or not).
for(unsigned int i=0; i<m_all_cached_meshes.size(); i++)
for (unsigned int i = 0; i < m_all_cached_meshes.size(); i++)
{
irr_driver->dropAllTextures(m_all_cached_meshes[i]);
// If a mesh is not in Irrlicht's texture cache, its refcount is
// 1 (since its scene node was removed, so the only other reference
// is in m_all_cached_meshes). In this case we only drop it once
// and don't try to remove it from the cache.
if(m_all_cached_meshes[i]->getReferenceCount()==1)
if (m_all_cached_meshes[i]->getReferenceCount() == 1)
{
m_all_cached_meshes[i]->drop();
continue;
}
m_all_cached_meshes[i]->drop();
if(m_all_cached_meshes[i]->getReferenceCount()==1)
if (m_all_cached_meshes[i]->getReferenceCount() == 1)
irr_driver->removeMeshFromCache(m_all_cached_meshes[i]);
}
m_all_cached_meshes.clear();
// Now free meshes that are not associated to any scene node.
for (unsigned int i=0; i<m_detached_cached_meshes.size(); i++)
for (unsigned int i = 0; i < m_detached_cached_meshes.size(); i++)
{
irr_driver->dropAllTextures(m_detached_cached_meshes[i]);
irr_driver->removeMeshFromCache(m_detached_cached_meshes[i]);
}
m_detached_cached_meshes.clear();
if(m_mini_map)
if (m_old_rtt_mini_map)
{
assert(m_mini_map->getReferenceCount()==1);
irr_driver->removeTexture(m_mini_map);
m_mini_map = NULL;
assert(m_old_rtt_mini_map->getReferenceCount() == 1);
irr_driver->removeTexture(m_old_rtt_mini_map);
m_old_rtt_mini_map = NULL;
}
if (m_new_rtt_mini_map)
{
delete m_new_rtt_mini_map;
m_new_rtt_mini_map = NULL;
}
for(unsigned int i=0; i<m_sky_textures.size(); i++)
@ -637,11 +643,18 @@ void Track::loadQuadGraph(unsigned int mode_id, const bool reverse)
m_mini_map_size = World::getWorld()->getRaceGUI()->getMiniMapSize();
core::dimension2du size = m_mini_map_size
.getOptimalSize(!nonpower,!nonsquare);
m_mini_map = QuadGraph::get()->makeMiniMap(size, "minimap::"+m_ident);
if (m_mini_map)
QuadGraph::get()->makeMiniMap(size, "minimap::" + m_ident, video::SColor(127, 255, 255, 255),
&m_old_rtt_mini_map, &m_new_rtt_mini_map);
if (m_old_rtt_mini_map)
{
m_minimap_x_scale = float(m_mini_map_size.Width) / float(m_mini_map->getSize().Width);
m_minimap_y_scale = float(m_mini_map_size.Height) / float(m_mini_map->getSize().Height);
m_minimap_x_scale = float(m_mini_map_size.Width) / float(m_old_rtt_mini_map->getSize().Width);
m_minimap_y_scale = float(m_mini_map_size.Height) / float(m_old_rtt_mini_map->getSize().Height);
}
else if (m_new_rtt_mini_map)
{
m_minimap_x_scale = float(m_mini_map_size.Width) / float(m_new_rtt_mini_map->getWidth());
m_minimap_y_scale = float(m_mini_map_size.Height) / float(m_new_rtt_mini_map->getHeight());
}
else
{

View File

@ -371,7 +371,8 @@ private:
video::SColor m_fog_color;
/** The texture for the mini map, which is displayed in the race gui. */
video::ITexture *m_mini_map;
video::ITexture *m_old_rtt_mini_map;
FrameBuffer *m_new_rtt_mini_map;
core::dimension2du m_mini_map_size;
float m_minimap_x_scale;
float m_minimap_y_scale;
@ -448,7 +449,8 @@ public:
std::vector< std::vector<float> > buildHeightMap();
// ------------------------------------------------------------------------
/** Returns the texture with the mini map for this track. */
const video::ITexture* getMiniMap () const { return m_mini_map; }
const video::ITexture* getOldRttMiniMap() const { return m_old_rtt_mini_map; }
const FrameBuffer* getNewRttMiniMap() const { return m_new_rtt_mini_map; }
// ------------------------------------------------------------------------
const core::dimension2du& getMiniMapSize() const { return m_mini_map_size; }
// ------------------------------------------------------------------------

View File

@ -51,7 +51,7 @@ public:
inline Vec3(const btVector3& a) : btVector3(a) {}
// ------------------------------------------------------------------------
/** Empty constructor. */
inline Vec3() : btVector3() {}
inline Vec3() : btVector3(0, 0, 0) {}
// ------------------------------------------------------------------------
/** Creates a 3d vector from three scalars. */
inline Vec3(float x, float y, float z) : btVector3(x,y,z) {}