Merge branch 'master' of github.com:supertuxkart/stk-code

This commit is contained in:
hiker 2014-10-31 15:32:26 +11:00
commit b56280761f
12 changed files with 104 additions and 17 deletions

View File

@ -43,11 +43,12 @@ float getShadowFactor(vec3 pos, float bias, int index)
//float shadowmapz = 2. * texture(shadowtex, vec3(shadowtexcoord, shadowcoord.z).x - 1.;
// bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping
float sum = 0.;
for (int i = 0; i < 4; i++)
for (float i = -1.5; i <= 1.5; i+= 1.)
{
sum += texture(shadowtex, vec4(shadowtexcoord + shadowoffset[i] / 2048., float(index), 0.5 * shadowcoord.z + 0.5));
for (float j = -1.5; j <= 1.5; j+= 1.)
sum += texture(shadowtex, vec4(shadowtexcoord +vec2(i, j) / 1024., float(index), 0.5 * shadowcoord.z + 0.5));
}
return sum / 4.;
return sum / 16.;
}
void main() {

View File

@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 2.6)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
cmake_policy(SET CMP0003 NEW)
project(Angelscript)
set(ANGELSCRIPT_SOURCE
../../source/as_atomic.cpp
../../source/as_builder.cpp

View File

@ -113,7 +113,7 @@ IrrDriver::IrrDriver()
m_post_processing = NULL;
m_wind = new Wind();
m_mipviz = m_wireframe = m_normals = m_ssaoviz = \
m_lightviz = m_shadowviz = m_distortviz = m_rsm = m_rh = m_gi = false;
m_lightviz = m_shadowviz = m_distortviz = m_rsm = m_rh = m_gi = m_boundingboxesviz = false;
SkyboxCubeMap = m_last_light_bucket_distance = 0;
m_shadow_camnodes[0] = NULL;
m_shadow_camnodes[1] = NULL;

View File

@ -345,6 +345,7 @@ private:
bool m_shadowviz;
bool m_lightviz;
bool m_distortviz;
bool m_boundingboxesviz;
/** Performance stats */
unsigned m_last_light_bucket_distance;
unsigned object_count[PASS_COUNT];
@ -623,6 +624,7 @@ public:
m_shadowviz = false;
m_lightviz = false;
m_distortviz = false;
m_boundingboxesviz = false;
}
// ------------------------------------------------------------------------
void toggleWireframe() { m_wireframe = !m_wireframe; }
@ -661,6 +663,10 @@ public:
// ------------------------------------------------------------------------
bool getDistortViz() { return m_distortviz; }
// ------------------------------------------------------------------------
void toggleBoundingBoxesViz() { m_boundingboxesviz = !m_boundingboxesviz; }
// ------------------------------------------------------------------------
bool getBoundingBoxesViz() { return m_boundingboxesviz; }
// ------------------------------------------------------------------------
u32 getRenderPass() { return m_renderpass; }
// ------------------------------------------------------------------------
void addGlowingNode(scene::ISceneNode *n, float r = 1.0f, float g = 1.0f, float b = 1.0f)

View File

@ -45,8 +45,12 @@
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
extern std::vector<float> BoundingBoxes;
void IrrDriver::renderGLSL(float dt)
{
BoundingBoxes.clear();
World *world = World::getWorld(); // Never NULL.
Track *track = world->getTrack();
@ -185,6 +189,23 @@ void IrrDriver::renderGLSL(float dt)
PROFILER_POP_CPU_MARKER();
renderScene(camnode, plc, glows, dt, track->hasShadows(), false);
// Render bounding boxes
if (irr_driver->getBoundingBoxesViz())
{
glUseProgram(UtilShader::ColoredLine::Program);
glBindVertexArray(UtilShader::ColoredLine::vao);
glBindBuffer(GL_ARRAY_BUFFER, UtilShader::ColoredLine::vbo);
UtilShader::ColoredLine::setUniforms(SColor(255, 255, 0, 0));
const float *tmp = BoundingBoxes.data();
for (unsigned int i = 0; i < BoundingBoxes.size(); i += 1024 * 6)
{
unsigned count = MIN2((int)BoundingBoxes.size() - i, 1024 * 6);
glBufferSubData(GL_ARRAY_BUFFER, 0, count * sizeof(float), &tmp[i]);
glDrawArrays(GL_LINES, 0, count / 3);
}
}
// Debug physic
// Note that drawAll must be called before rendering
// the bullet debug view, since otherwise the camera

View File

@ -978,6 +978,8 @@ void IrrDriver::renderShadows()
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.5, 0.);
m_rtts->getShadowFBO().Bind();
@ -1022,6 +1024,7 @@ void IrrDriver::renderShadows()
}
glDisable(GL_POLYGON_OFFSET_FILL);
glCullFace(GL_BACK);
}

View File

@ -286,7 +286,10 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb, const std::string &matname)
{
if (!mesh.textures[i])
{
Log::fatal("STKMesh", "Missing texture %d for material %s", i, matname.c_str());
#ifdef DEBUG
Log::fatal("STKMesh", "Missing texture %d for material %s, mesh <%s>",
i, matname.c_str(), mesh.debug_name.c_str());
#endif
return;
}
compressTexture(mesh.textures[i], isSrgb);
@ -370,4 +373,4 @@ void InitTexturesTransparent(GLMesh &mesh)
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
}
}
}

View File

@ -166,6 +166,18 @@ bool isBoxInFrontOfPlane(const core::plane3df &plane, const core::vector3df edge
return true;
}
std::vector<float> BoundingBoxes;
static void addEdge(const core::vector3df &P0, const core::vector3df &P1)
{
BoundingBoxes.push_back(P0.X);
BoundingBoxes.push_back(P0.Y);
BoundingBoxes.push_back(P0.Z);
BoundingBoxes.push_back(P1.X);
BoundingBoxes.push_back(P1.Y);
BoundingBoxes.push_back(P1.Z);
}
static
bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node)
{
@ -175,11 +187,6 @@ bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode
const core::matrix4 &trans = node->getAbsoluteTransformation();
const scene::SViewFrustum &frust = *cam->getViewFrustum();
core::aabbox3d<f32> tbox = node->getBoundingBox();
trans.transformBoxEx(tbox);
if (!(tbox.intersectsWithBox(frust.getBoundingBox())))
return true;
core::vector3df edges[8];
node->getBoundingBox().getEdges(edges);
for (unsigned i = 0; i < 8; i++)
@ -201,6 +208,41 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
node->updateNoGL();
DeferredUpdate.push_back(node);
const core::matrix4 &trans = Node->getAbsoluteTransformation();
core::vector3df edges[8];
Node->getBoundingBox().getEdges(edges);
for (unsigned i = 0; i < 8; i++)
trans.transformVect(edges[i]);
/* From irrlicht
/3--------/7
/ | / |
/ | / |
1---------5 |
| /2- - -|- -6
| / | /
|/ | /
0---------4/
*/
if (irr_driver->getBoundingBoxesViz())
{
addEdge(edges[0], edges[1]);
addEdge(edges[1], edges[5]);
addEdge(edges[5], edges[4]);
addEdge(edges[4], edges[0]);
addEdge(edges[2], edges[3]);
addEdge(edges[3], edges[7]);
addEdge(edges[7], edges[6]);
addEdge(edges[6], edges[2]);
addEdge(edges[0], edges[2]);
addEdge(edges[1], edges[3]);
addEdge(edges[5], edges[7]);
addEdge(edges[4], edges[6]);
}
if (node->isImmediateDraw())
{
ImmediateDraw->push_back(Node);

View File

@ -42,7 +42,7 @@ namespace GUIEngine
GAME,
INGAME_MENU,
/** Dummy GameState e. g. for parameters. */
CURRENT = MENU | GAME | INGAME_MENU
CURRENT
}; // GameState
/**

View File

@ -24,6 +24,7 @@
#include "challenges/challenge_data.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "graphics/material_manager.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp"
#include "io/file_manager.hpp"
@ -299,7 +300,7 @@ void FeatureUnlockedCutScene::init()
m_unlocked_stuff[n].m_root_gift_node = kart_model->attachModel(true, false);
m_unlocked_stuff[n].m_scale = 5.0f;
kart_model->setAnimation(KartModel::AF_DEFAULT);
kart_model->update(0.0f, 0.0f, 0.0f, 0.0f);
//kart_model->update(0.0f, 0.0f, 0.0f, 0.0f);
#ifdef DEBUG
m_unlocked_stuff[n].m_root_gift_node->setName("unlocked kart");
@ -337,12 +338,14 @@ void FeatureUnlockedCutScene::init()
m_unlocked_stuff[n].m_w,
m_unlocked_stuff[n].m_h);
m_unlocked_stuff[n].m_root_gift_node = irr_driver->getSceneManager()->addEmptySceneNode();
irr_driver->setAllMaterialFlags(mesh);
m_unlocked_stuff[n].m_side_1 = irr_driver->addMesh(mesh, "unlocked_picture", m_unlocked_stuff[n].m_root_gift_node);
//mesh->drop();
mesh = irr_driver->createTexturedQuadMesh(&m,
m_unlocked_stuff[n].m_w,
m_unlocked_stuff[n].m_h);
irr_driver->setAllMaterialFlags(mesh);
m_unlocked_stuff[n].m_side_2 = irr_driver->addMesh(mesh, "unlocked_picture", m_unlocked_stuff[n].m_root_gift_node);
m_unlocked_stuff[n].m_side_2->setRotation(core::vector3df(0.0f, 180.0f, 0.0f));
//mesh->drop();

View File

@ -1202,6 +1202,7 @@ bool Track::loadMainTrack(const XMLNode &root)
bool lod_instance = false;
n->get("lod_instance", &lod_instance);
/*
if (tangent)
{
scene::IMesh* original_mesh = irr_driver->getMesh(full_path);
@ -1243,7 +1244,8 @@ bool Track::loadMainTrack(const XMLNode &root)
handleAnimatedTextures(scene_node, *n);
m_all_nodes.push_back( scene_node );
}
else if (lod_instance)
else*/
if (lod_instance)
{
LODNode* node = lodLoader.instanciateAsLOD(n, NULL);
if (node != NULL)
@ -1267,6 +1269,8 @@ bool Track::loadMainTrack(const XMLNode &root)
continue;
}
a_mesh = MeshTools::createMeshWithTangents(a_mesh, &MeshTools::isNormalMap);
// The meshes loaded here are in irrlicht's mesh cache. So we
// have to keep track of them in order to properly remove them
// from memory. We could add each track only once in a list, but

View File

@ -67,6 +67,7 @@ enum DebugMenuCommand
DEBUG_GRAPHICS_DISTORT_VIZ,
DEBUG_GRAPHICS_BULLET_1,
DEBUG_GRAPHICS_BULLET_2,
DEBUG_GRAPHICS_BOUNDING_BOXES_VIZ,
DEBUG_PROFILER,
DEBUG_PROFILER_GENERATE_REPORT,
DEBUG_FPS,
@ -173,6 +174,7 @@ bool onEvent(const SEvent &event)
sub->addItem(L"Distort viz", DEBUG_GRAPHICS_DISTORT_VIZ );
sub->addItem(L"Physics debug", DEBUG_GRAPHICS_BULLET_1);
sub->addItem(L"Physics debug (no kart)", DEBUG_GRAPHICS_BULLET_2);
sub->addItem(L"Bounding Boxes viz", DEBUG_GRAPHICS_BOUNDING_BOXES_VIZ);
sub->addItem(L"Reset debug views", DEBUG_GRAPHICS_RESET );
mnu->addItem(L"Items >",-1,true,true);
@ -342,6 +344,11 @@ bool onEvent(const SEvent &event)
Physics *physics = world->getPhysics();
physics->setDebugMode(IrrDebugDrawer::DM_NO_KARTS_GRAPHICS);
}
else if (cmdID == DEBUG_GRAPHICS_BOUNDING_BOXES_VIZ)
{
irr_driver->resetDebugModes();
irr_driver->toggleBoundingBoxesViz();
}
else if (cmdID == DEBUG_PROFILER)
{
UserConfigParams::m_profiler_enabled =