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

This commit is contained in:
hiker 2016-11-28 12:46:00 +11:00
commit 21ca9b40f0
25 changed files with 274 additions and 377 deletions

View File

@ -172,7 +172,6 @@ namespace scene
\return The non-transformed bounding box. */
virtual const core::aabbox3d<f32>& getBoundingBox() const = 0;
//! Get the axis aligned, transformed and animated absolute bounding box of this node.
/** \return The transformed bounding box. */
virtual const core::aabbox3d<f32> getTransformedBoundingBox() const
@ -590,6 +589,12 @@ namespace scene
return Children;
}
//! Returns a list of all children (non-const version).
/** \return The list of all children of this node. */
core::list<ISceneNode*>& getChildren()
{
return Children;
}
//! Changes the parent of the scene node.
/** \param newParent The new parent to be used. */

View File

@ -1,5 +1,5 @@
# Modify this file to change the last-modified date when you add/remove a file.
# This will then trigger a new cmake run automatically.
# This will then trigger a new cmake run automatically.
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")

View File

@ -298,10 +298,13 @@ public:
#endif
TexExpander<typename T::InstancedFirstPassShader>::template
expandTex(*mesh, T::FirstPassTextures);
if (!mesh->mb->getMaterial().BackfaceCulling)
glDisable(GL_CULL_FACE);
glDrawElementsIndirect(GL_TRIANGLES,
GL_UNSIGNED_SHORT,
(const void*)((m_offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
if (!mesh->mb->getMaterial().BackfaceCulling)
glEnable(GL_CULL_FACE);
}
} //drawIndirectFirstPass
@ -366,11 +369,13 @@ public:
(mesh->m_render_info->getHue(),
mesh->m_material->getColorizationFactor());
}
if (!mesh->mb->getMaterial().BackfaceCulling)
glDisable(GL_CULL_FACE);
glDrawElementsIndirect(GL_TRIANGLES,
GL_UNSIGNED_SHORT,
(const void*)((m_offset[T::MaterialType] + i) * sizeof(DrawElementsIndirectCommand)));
if (!mesh->mb->getMaterial().BackfaceCulling)
glEnable(GL_CULL_FACE);
if (need_change_hue)
{
// Reset after changing

View File

@ -25,26 +25,11 @@
#include "graphics/stk_billboard.hpp"
#include "graphics/stk_mesh.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/stk_scene_manager.hpp"
#include "graphics/vao_manager.hpp"
#include "modes/world.hpp"
#include "tracks/track.hpp"
#include "utils/profiler.hpp"
using namespace irr;
namespace
{
void FixBoundingBoxes(scene::ISceneNode* node)
{
for (scene::ISceneNode *child : node->getChildren())
{
FixBoundingBoxes(child);
const_cast<core::aabbox3df&>(node->getBoundingBox()).addInternalBox(child->getBoundingBox());
}
}
} //namespace
// ----------------------------------------------------------------------------
void DrawCalls::clearLists()
{
@ -72,27 +57,16 @@ void DrawCalls::clearLists()
}
// ----------------------------------------------------------------------------
void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
std::vector<scene::ISceneNode *> *ImmediateDraw,
const scene::ICameraSceneNode *cam,
scene::ICameraSceneNode *shadowcam[4],
const scene::ICameraSceneNode *rsmcam,
bool &culledforcam,
bool culledforshadowcam[4],
bool &culledforrsm,
bool drawRSM)
bool DrawCalls::isCulledPrecise(const scene::ICameraSceneNode *cam,
const scene::ISceneNode* node,
bool visualization)
{
STKMeshCommon *node = dynamic_cast<STKMeshCommon*>(Node);
if (!node)
return;
node->updateNoGL();
m_deferred_update.push_back(node);
const core::matrix4 &trans = Node->getAbsoluteTransformation();
if (!node->getAutomaticCulling() && !visualization)
return false;
const core::matrix4 &trans = node->getAbsoluteTransformation();
core::vector3df edges[8];
Node->getBoundingBox().getEdges(edges);
node->getBoundingBox().getEdges(edges);
for (unsigned i = 0; i < 8; i++)
trans.transformVect(edges[i]);
@ -107,35 +81,119 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
0---------4/
*/
if (irr_driver->getBoundingBoxesViz())
if (visualization)
{
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]);
addEdgeForViz(edges[0], edges[1]);
addEdgeForViz(edges[1], edges[5]);
addEdgeForViz(edges[5], edges[4]);
addEdgeForViz(edges[4], edges[0]);
addEdgeForViz(edges[2], edges[3]);
addEdgeForViz(edges[3], edges[7]);
addEdgeForViz(edges[7], edges[6]);
addEdgeForViz(edges[6], edges[2]);
addEdgeForViz(edges[0], edges[2]);
addEdgeForViz(edges[1], edges[3]);
addEdgeForViz(edges[5], edges[7]);
addEdgeForViz(edges[4], edges[6]);
if (!node->getAutomaticCulling())
{
return false;
}
}
const scene::SViewFrustum &frust = *cam->getViewFrustum();
for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; i++)
{
if (isBoxInFrontOfPlane(frust.planes[i], edges))
{
return true;
}
}
return false;
} // isCulledPrecise
// ----------------------------------------------------------------------------
bool DrawCalls::isBoxInFrontOfPlane(const core::plane3df &plane,
const core::vector3df* edges)
{
for (u32 i = 0; i < 8; i++)
{
if (plane.classifyPointRelation(edges[i]) != core::ISREL3D_FRONT)
return false;
}
return true;
} // isBoxInFrontOfPlane
// ----------------------------------------------------------------------------
void DrawCalls::addEdgeForViz(const core::vector3df &p0,
const core::vector3df &p1)
{
m_bounding_boxes.push_back(p0.X);
m_bounding_boxes.push_back(p0.Y);
m_bounding_boxes.push_back(p0.Z);
m_bounding_boxes.push_back(p1.X);
m_bounding_boxes.push_back(p1.Y);
m_bounding_boxes.push_back(p1.Z);
} // addEdgeForViz
// ----------------------------------------------------------------------------
void DrawCalls::renderBoundingBoxes()
{
Shaders::ColoredLine *line = Shaders::ColoredLine::getInstance();
line->use();
line->bindVertexArray();
line->bindBuffer();
line->setUniforms(irr::video::SColor(255, 255, 0, 0));
const float *tmp = m_bounding_boxes.data();
for (unsigned int i = 0; i < m_bounding_boxes.size(); i += 1024 * 6)
{
unsigned count = std::min((unsigned)m_bounding_boxes.size() - i,
(unsigned)1024 * 6);
glBufferSubData(GL_ARRAY_BUFFER, 0, count * sizeof(float), &tmp[i]);
glDrawArrays(GL_LINES, 0, count / 3);
}
m_bounding_boxes.clear();
} // renderBoundingBoxes
// ----------------------------------------------------------------------------
void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
std::vector<scene::ISceneNode *> *ImmediateDraw,
const scene::ICameraSceneNode *cam,
ShadowMatrices& shadow_matrices)
{
STKMeshCommon* node = dynamic_cast<STKMeshCommon*>(Node);
if (!node)
return;
node->updateNoGL();
m_deferred_update.push_back(node);
if (node->isImmediateDraw())
{
ImmediateDraw->push_back(Node);
return;
}
culledforcam = culledforcam || isCulledPrecise(cam, Node);
culledforrsm = culledforrsm || isCulledPrecise(rsmcam, Node);
for (unsigned i = 0; i < 4; i++)
culledforshadowcam[i] = culledforshadowcam[i] || isCulledPrecise(shadowcam[i], Node);
bool culled_for_cams[6] = { true, true, true, true, true, true };
culled_for_cams[0] = isCulledPrecise(cam, Node,
irr_driver->getBoundingBoxesViz());
if (UserConfigParams::m_gi && !shadow_matrices.isRSMMapAvail())
{
culled_for_cams[1] = isCulledPrecise(shadow_matrices.getSunCam(), Node);
}
if (CVS->isShadowEnabled())
{
for (unsigned i = 0; i < 4; i++)
{
culled_for_cams[i + 2] =
isCulledPrecise(shadow_matrices.getShadowCamNodes()[i], Node);
}
}
// Transparent
if (World::getWorld() && World::getWorld()->isFogEnabled())
{
const Track * const track = World::getWorld()->getTrack();
@ -185,7 +243,7 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
for (GLMesh *mesh : node->TransparentMesh[TM_DISPLACEMENT])
pushVector(ListDisplacement::getInstance(), mesh, Node->getAbsoluteTransformation());
if (!culledforcam)
if (!culled_for_cams[0])
{
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
{
@ -212,7 +270,10 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
switch (Mat)
{
case Material::SHADERTYPE_SOLID:
ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix,
(mesh->m_render_info && mesh->m_material ?
core::vector2df(mesh->m_render_info->getHue(), mesh->m_material->getColorizationFactor()) :
core::vector2df(0.0f, 0.0f)));
break;
case Material::SHADERTYPE_ALPHA_TEST:
ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
@ -223,7 +284,6 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
case Material::SHADERTYPE_SPLATTING:
ListMatSplatting::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix);
break;
case Material::SHADERTYPE_ALPHA_BLEND:
break;
case Material::SHADERTYPE_ADDITIVE:
@ -238,7 +298,6 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
break;
case Material::SHADERTYPE_DETAIL_MAP:
break;
default:
Log::warn("DrawCalls", "Unknown material type: %d", Mat);
}
@ -255,13 +314,19 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
switch (Mat)
{
case Material::SHADERTYPE_SOLID:
ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix,
(mesh->m_render_info && mesh->m_material ?
core::vector2df(mesh->m_render_info->getHue(), mesh->m_material->getColorizationFactor()) :
core::vector2df(0.0f, 0.0f)));
break;
case Material::SHADERTYPE_ALPHA_TEST:
ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
break;
case Material::SHADERTYPE_NORMAL_MAP:
ListMatNormalMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
ListMatNormalMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix,
(mesh->m_render_info && mesh->m_material ?
core::vector2df(mesh->m_render_info->getHue(), mesh->m_material->getColorizationFactor()) :
core::vector2df(0.0f, 0.0f)));
break;
case Material::SHADERTYPE_DETAIL_MAP:
ListMatDetails::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
@ -278,14 +343,12 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
case Material::SHADERTYPE_VEGETATION:
ListMatGrass::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, m_wind_dir);
break;
case Material::SHADERTYPE_ALPHA_BLEND:
break;
case Material::SHADERTYPE_ADDITIVE:
break;
case Material::SHADERTYPE_WATER:
break;
default:
Log::warn("DrawCalls", "Unknown material type: %d", Mat);
}
@ -297,7 +360,7 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
return;
for (unsigned cascade = 0; cascade < 4; ++cascade)
{
if (culledforshadowcam[cascade])
if (culled_for_cams[cascade + 2])
continue;
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
{
@ -319,13 +382,13 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
switch (Mat)
{
case Material::SHADERTYPE_SOLID:
ListMatDefault::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
ListMatDefault::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f));
break;
case Material::SHADERTYPE_ALPHA_TEST:
ListMatAlphaRef::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
break;
case Material::SHADERTYPE_NORMAL_MAP:
ListMatNormalMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
ListMatNormalMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f));
break;
case Material::SHADERTYPE_DETAIL_MAP:
ListMatDetails::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
@ -341,14 +404,12 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
break;
case Material::SHADERTYPE_VEGETATION:
ListMatGrass::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, m_wind_dir);
case Material::SHADERTYPE_ALPHA_BLEND:
break;
case Material::SHADERTYPE_ADDITIVE:
break;
case Material::SHADERTYPE_WATER:
break;
default:
Log::warn("DrawCalls", "Unknown material type: %d", Mat);
}
@ -356,21 +417,23 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
}
}
}
if (!UserConfigParams::m_gi || !drawRSM)
if (!UserConfigParams::m_gi || shadow_matrices.isRSMMapAvail())
return;
if (!culledforrsm)
if (!culled_for_cams[1])
{
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
{
if (CVS->supportsIndirectInstancingRendering())
{
if (Mat == Material::SHADERTYPE_SPLATTING)
{
for (GLMesh *mesh : node->MeshSolidMaterial[Mat])
{
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
ModelMatrix.getInverse(InvModelMatrix);
ListMatSplatting::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix);
}
ListMatSplatting::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix);
}
}
else
{
for (GLMesh *mesh : node->MeshSolidMaterial[Mat])
@ -382,7 +445,6 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
}
else
{
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
ModelMatrix.getInverse(InvModelMatrix);
@ -391,13 +453,13 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
switch (Mat)
{
case Material::SHADERTYPE_SOLID:
ListMatDefault::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
ListMatDefault::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f));
break;
case Material::SHADERTYPE_ALPHA_TEST:
ListMatAlphaRef::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
break;
case Material::SHADERTYPE_NORMAL_MAP:
ListMatNormalMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
ListMatNormalMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f));
break;
case Material::SHADERTYPE_DETAIL_MAP:
ListMatDetails::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix);
@ -414,14 +476,12 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
case Material::SHADERTYPE_VEGETATION:
ListMatGrass::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, m_wind_dir);
break;
case Material::SHADERTYPE_ALPHA_BLEND:
break;
case Material::SHADERTYPE_ADDITIVE:
break;
case Material::SHADERTYPE_WATER:
break;
default:
Log::warn("DrawCalls", "Unknown material type: %d", Mat);
}
@ -431,16 +491,11 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
}
}
// ----------------------------------------------------------------------------
void DrawCalls::parseSceneManager(core::list<scene::ISceneNode*> &List,
std::vector<scene::ISceneNode *> *ImmediateDraw,
const scene::ICameraSceneNode* cam,
scene::ICameraSceneNode *shadow_cam[4],
const scene::ICameraSceneNode *rsmcam,
bool culledforcam,
bool culledforshadowcam[4],
bool culledforrsm,
bool drawRSM)
const scene::ICameraSceneNode *cam,
ShadowMatrices& shadow_matrices)
{
core::list<scene::ISceneNode*>::Iterator I = List.begin(), E = List.end();
for (; I != E; ++I)
@ -465,13 +520,9 @@ void DrawCalls::parseSceneManager(core::list<scene::ISceneNode*> &List,
continue;
}
bool newculledforcam = culledforcam;
bool newculledforrsm = culledforrsm;
bool newculledforshadowcam[4] = { culledforshadowcam[0], culledforshadowcam[1], culledforshadowcam[2], culledforshadowcam[3] };
handleSTKCommon(*I, ImmediateDraw, cam, shadow_cam, rsmcam, newculledforcam, newculledforshadowcam, newculledforrsm, drawRSM);
parseSceneManager(const_cast<core::list<scene::ISceneNode*>& >((*I)->getChildren()), ImmediateDraw, cam, shadow_cam, rsmcam, newculledforcam, newculledforshadowcam, newculledforrsm, drawRSM);
handleSTKCommon((*I), ImmediateDraw, cam, shadow_matrices);
parseSceneManager((*I)->getChildren(), ImmediateDraw, cam,
shadow_matrices);
}
}
@ -506,15 +557,13 @@ DrawCalls::~DrawCalls()
#endif // !defined(USE_GLES2)
} //~DrawCalls
// ----------------------------------------------------------------------------
/** Prepare draw calls before scene rendering
* \param[out] solid_poly_count Total number of polygons in objects
* that will be rendered in this frame
* \param[out] shadow_poly_count Total number of polygons for shadow
* (rendered this frame)
*/
*/
void DrawCalls::prepareDrawCalls( ShadowMatrices& shadow_matrices,
scene::ICameraSceneNode *camnode,
unsigned &solid_poly_count,
@ -533,23 +582,11 @@ void DrawCalls::prepareDrawCalls( ShadowMatrices& shadow_matrices,
m_glow_pass_mesh.clear();
m_deferred_update.clear();
core::list<scene::ISceneNode*> List = irr_driver->getSceneManager()->getRootSceneNode()->getChildren();
PROFILER_PUSH_CPU_MARKER("- culling", 0xFF, 0xFF, 0x0);
for (scene::ISceneNode *child : List)
FixBoundingBoxes(child);
bool cam = false, rsmcam = false;
bool shadowcam[4] = { false, false, false, false };
parseSceneManager(List,
&m_immediate_draw_list,
camnode,
shadow_matrices.getShadowCamNodes(),
shadow_matrices.getSunCam(),
cam, shadowcam, rsmcam,
!shadow_matrices.isRSMMapAvail());
parseSceneManager(
irr_driver->getSceneManager()->getRootSceneNode()->getChildren(),
&m_immediate_draw_list, camnode, shadow_matrices);
PROFILER_POP_CPU_MARKER();
// Add a 1 s timeout

View File

@ -37,6 +37,8 @@ private:
std::vector<STKBillboard *> m_billboard_list;
std::vector<ParticleSystemProxy *> m_particles_list;
std::vector<float> m_bounding_boxes;
/** meshes to draw */
SolidPassMeshMap m_solid_pass_mesh [ Material::SHADERTYPE_COUNT];
OtherMeshMap m_shadow_pass_mesh [4 * Material::SHADERTYPE_COUNT];
@ -56,23 +58,22 @@ private:
void handleSTKCommon(scene::ISceneNode *Node,
std::vector<scene::ISceneNode *> *ImmediateDraw,
const scene::ICameraSceneNode *cam,
scene::ICameraSceneNode *shadowcam[4],
const scene::ICameraSceneNode *rsmcam,
bool &culledforcam,
bool culledforshadowcam[4],
bool &culledforrsm,
bool drawRSM);
void parseSceneManager(core::list<scene::ISceneNode*> &List,
std::vector<scene::ISceneNode *> *ImmediateDraw,
const scene::ICameraSceneNode* cam,
scene::ICameraSceneNode *shadow_cam[4],
const scene::ICameraSceneNode *rsmcam,
bool culledforcam,
bool culledforshadowcam[4],
bool culledforrsm,
bool drawRSM);
ShadowMatrices& shadow_matrices);
void parseSceneManager(core::list<scene::ISceneNode*> &List,
std::vector<scene::ISceneNode *> *ImmediateDraw,
const scene::ICameraSceneNode *cam,
ShadowMatrices& shadow_matrices);
bool isCulledPrecise(const scene::ICameraSceneNode *cam,
const scene::ISceneNode* node,
bool visualization = false);
bool isBoxInFrontOfPlane(const core::plane3df &plane,
const core::vector3df* edges);
void addEdgeForViz(const core::vector3df &p0, const core::vector3df &p1);
public:
DrawCalls();
~DrawCalls();
@ -103,7 +104,7 @@ public:
void drawIndirectGlow() const;
void multidrawGlow() const;
void renderBoundingBoxes();
};
#endif //HEADER_DRAW_CALLS_HPP

View File

@ -109,7 +109,6 @@ void renderShadow(unsigned cascade)
} // for i
} // renderShadow
// ----------------------------------------------------------------------------
template<typename T, int... Selector>
void drawRSM(const core::matrix4 & rsm_matrix)
@ -132,8 +131,6 @@ void drawRSM(const core::matrix4 & rsm_matrix)
}
} // drawRSM
// ----------------------------------------------------------------------------
void GL3DrawPolicy::drawSolidFirstPass(const DrawCalls& draw_calls) const
{
@ -152,14 +149,14 @@ void GL3DrawPolicy::drawSolidSecondPass (const DrawCalls& draw_calls,
const std::vector<uint64_t>& handles,
const std::vector<GLuint>& prefilled_tex) const
{
renderMeshes2ndPass<DefaultMaterial, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<AlphaRef, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<UnlitMat, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<SplattingMat, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<SphereMap, 2, 1> (handles, prefilled_tex);
renderMeshes2ndPass<DetailMat, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<GrassMat, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<NormalMat, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<DefaultMaterial, 4, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<AlphaRef, 3, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<UnlitMat, 3, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<SplattingMat, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<SphereMap, 2, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<DetailMat, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<GrassMat, 3, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<NormalMat, 4, 3, 1> (handles, prefilled_tex);
}
// ----------------------------------------------------------------------------
@ -220,11 +217,11 @@ void IndirectDrawPolicy::drawSolidSecondPass (const DrawCalls& draw_calls,
#if !defined(USE_GLES2)
//TODO: find a way to add TextureMatrix in instanced shaders,
//and remove these four lines
renderMeshes2ndPass<DefaultMaterial, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<AlphaRef, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<UnlitMat, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<SplattingMat, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<DefaultMaterial, 4, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<AlphaRef, 3, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<UnlitMat, 3, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<SplattingMat, 1 > (handles, prefilled_tex);
draw_calls.drawIndirectSolidSecondPass(prefilled_tex);
#endif //!defined(USE_GLES2)
}
@ -293,11 +290,11 @@ void MultidrawPolicy::drawSolidSecondPass (const DrawCalls& draw_calls,
#if !defined(USE_GLES2)
//TODO: find a way to add TextureMarix in instanced shaders,
//and remove these four lines
renderMeshes2ndPass<DefaultMaterial, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<AlphaRef, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<UnlitMat, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<SplattingMat, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<DefaultMaterial, 4, 3, 1> (handles, prefilled_tex);
renderMeshes2ndPass<AlphaRef, 3, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<UnlitMat, 3, 1 > (handles, prefilled_tex);
renderMeshes2ndPass<SplattingMat, 1 > (handles, prefilled_tex);
draw_calls.multidrawSolidSecondPass(handles);
#endif //!defined(USE_GLES2)
}

View File

@ -64,37 +64,19 @@ struct CustomUnrollArgs<>
{
irr_driver->increaseObjectCount(); //TODO: move somewhere else
GLMesh *mesh = STK::tuple_get<0>(t);
//shadow_custom_unroll_args, rsm_custom_unroll_args and custom_unroll_args
// have been merged in order to avoid duplicated code.
// don't need to call change color things for shadows and rsm
//TODO: don't call next 10 lines for shadow/rsm shaders?
const bool support_change_hue = (mesh->m_render_info != NULL &&
mesh->m_material != NULL);
const bool need_change_hue = (support_change_hue &&
mesh->m_render_info->getHue() > 0.0f);
if (need_change_hue)
{
S::getInstance()->changeableColor(mesh->m_render_info->getHue(),
mesh->m_material->getColorizationFactor());
}
if (!mesh->mb->getMaterial().BackfaceCulling)
glDisable(GL_CULL_FACE);
S::getInstance()->setUniforms(args...);
glDrawElementsBaseVertex(mesh->PrimitiveType,
(int)mesh->IndexCount,
mesh->IndexType,
(GLvoid *)mesh->vaoOffset,
(int)mesh->vaoBaseVertex);
if (need_change_hue)
{
// Reset after changing
S::getInstance()->changeableColor();
}
if (!mesh->mb->getMaterial().BackfaceCulling)
glEnable(GL_CULL_FACE);
} // drawMesh
}; // CustomUnrollArgs
// ----------------------------------------------------------------------------
/** Variadic template to implement TexExpander*/
template<typename T, int N>

View File

@ -22,7 +22,6 @@
#include "graphics/post_processing.hpp"
#include "graphics/rtts.hpp"
#include "graphics/shaders.hpp"
#include "graphics/stk_scene_manager.hpp"
#include "modes/world.hpp"
#include "utils/tuple.hpp"
#include <SColor.h>

View File

@ -37,7 +37,6 @@
#include "graphics/stk_animated_mesh.hpp"
#include "graphics/stk_billboard.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/stk_scene_manager.hpp"
#include "graphics/sun.hpp"
#include "graphics/texture_manager.hpp"
#include "guiengine/engine.hpp"

View File

@ -547,16 +547,11 @@ void LightingPasses::updateLightsInfo(scene::ICameraSceneNode * const camnode,
} // updateLightsInfo
// ----------------------------------------------------------------------------
void LightingPasses::renderGlobalIllumination( const ShadowMatrices& shadow_matrices,
const FrameBuffer& radiance_hint_framebuffer,
const FrameBuffer& reflective_shadow_map_framebuffer,
const FrameBuffer& diffuse_framebuffer,
GLuint normal_depth_texture,
GLuint depth_stencil_texture)
void LightingPasses::renderRadianceHints( const ShadowMatrices& shadow_matrices,
const FrameBuffer& radiance_hint_framebuffer,
const FrameBuffer& reflective_shadow_map_framebuffer)
{
//Radiance hints
#if !defined(USE_GLES2)
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_RH));
glDisable(GL_BLEND);
radiance_hint_framebuffer.bind();
glBindVertexArray(SharedGPUObjects::getFullScreenQuadVAO());
@ -595,18 +590,18 @@ void LightingPasses::renderGlobalIllumination( const ShadowMatrices& shadow_mat
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, 32);
}
#endif //!defined(USE_GLES2)
} // renderRadianceHints
//Global illumination
{
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_GI));
diffuse_framebuffer.bind();
GlobalIlluminationReconstructionShader::getInstance()
->render(shadow_matrices.getRHMatrix(),
shadow_matrices.getRHExtend(),
radiance_hint_framebuffer,
normal_depth_texture,
depth_stencil_texture);
}
// ----------------------------------------------------------------------------
void LightingPasses::renderGlobalIllumination( const ShadowMatrices& shadow_matrices,
const FrameBuffer& radiance_hint_framebuffer,
GLuint normal_depth_texture,
GLuint depth_stencil_texture)
{
GlobalIlluminationReconstructionShader::getInstance()
->render(shadow_matrices.getRHMatrix(), shadow_matrices.getRHExtend(),
radiance_hint_framebuffer, normal_depth_texture,
depth_stencil_texture);
}
// ----------------------------------------------------------------------------
@ -614,19 +609,15 @@ void LightingPasses::renderLights( bool has_shadow,
GLuint normal_depth_texture,
GLuint depth_stencil_texture,
const FrameBuffer& shadow_framebuffer,
const FrameBuffer& diffuse_specular_framebuffer,
GLuint specular_probe)
{
diffuse_specular_framebuffer.bind();
glClear(GL_COLOR_BUFFER_BIT);
{
{
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_ENVMAP));
renderEnvMap(normal_depth_texture,
depth_stencil_texture,
specular_probe);
}
}
// Render sunlight if and only if track supports shadow
if (!World::getWorld() || World::getWorld()->getTrack()->hasShadows())
{

View File

@ -47,18 +47,19 @@ public:
void updateLightsInfo(irr::scene::ICameraSceneNode * const camnode,
float dt);
void renderRadianceHints( const ShadowMatrices& shadow_matrices,
const FrameBuffer& radiance_hint_framebuffer,
const FrameBuffer& reflective_shadow_map_framebuffer);
void renderGlobalIllumination( const ShadowMatrices& shadow_matrices,
const FrameBuffer& radiance_hint_framebuffer,
const FrameBuffer& reflective_shadow_map_framebuffer,
const FrameBuffer& diffuse_framebuffer,
GLuint normal_depth_texture,
GLuint depth_stencil_texture);
void renderLights( bool has_shadow,
GLuint normal_depth_texture,
GLuint depth_stencil_texture,
const FrameBuffer& shadow_framebuffer,
const FrameBuffer& diffuse_specular_framebuffer,
GLuint specular_probe);
void renderAmbientScatter(GLuint depth_stencil_texture);
void renderLightsScatter(GLuint depth_stencil_texture,

View File

@ -716,6 +716,10 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
m_texname.c_str());
}
// Backface culling
if(!m_backface_culling)
m->setFlag(video::EMF_BACK_FACE_CULLING, false);
if (CVS->isGLSL())
{
ITexture *tex;
@ -992,10 +996,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
}
}
// Backface culling
if(!m_backface_culling)
m->setFlag(video::EMF_BACK_FACE_CULLING, false);
// Material color
m->ColorMaterial = video::ECM_DIFFUSE_AND_AMBIENT;

View File

@ -181,7 +181,7 @@ public:
loadProgram(OBJECT, GL_VERTEX_SHADER, "rsm.vert",
GL_FRAGMENT_SHADER, "rsm.frag");
assignUniforms("RSMMatrix", "ModelMatrix", "TextureMatrix");
assignUniforms("ModelMatrix", "TextureMatrix", "RSMMatrix");
assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
} // CRSMShader
}; // CRSMShader
@ -197,7 +197,7 @@ public:
loadProgram(OBJECT, GL_VERTEX_SHADER, "rsm.vert",
GL_FRAGMENT_SHADER, "splatting_rsm.frag");
assignUniforms("RSMMatrix", "ModelMatrix");
assignUniforms("ModelMatrix", "RSMMatrix");
assignSamplerNames(0, "tex_layout", ST_TRILINEAR_ANISOTROPIC_FILTERED,
1, "tex_detail0", ST_TRILINEAR_ANISOTROPIC_FILTERED,
2, "tex_detail1", ST_TRILINEAR_ANISOTROPIC_FILTERED,

View File

@ -1293,7 +1293,8 @@ void PostProcessing::renderDoF(const FrameBuffer &framebuffer, GLuint color_text
// ----------------------------------------------------------------------------
void PostProcessing::renderGodRays(scene::ICameraSceneNode * const camnode,
const FrameBuffer &fbo,
const FrameBuffer &in_fbo,
const FrameBuffer &out_fbo,
const FrameBuffer &quarter1_fbo,
const FrameBuffer &quarter2_fbo)
{
@ -1301,7 +1302,7 @@ void PostProcessing::renderGodRays(scene::ICameraSceneNode * const camnode,
glEnable(GL_DEPTH_TEST);
// Grab the sky
fbo.bind();
out_fbo.bind();
glClear(GL_COLOR_BUFFER_BIT);
// irr_driver->renderSkybox(camnode);
@ -1321,7 +1322,7 @@ void PostProcessing::renderGodRays(scene::ICameraSceneNode * const camnode,
quarter1_fbo.bind();
glViewport(0, 0, irr_driver->getActualScreenSize().Width / 4,
irr_driver->getActualScreenSize().Height / 4);
GodFadeShader::getInstance()->render(fbo.getRTT()[0], col);
GodFadeShader::getInstance()->render(out_fbo.getRTT()[0], col);
// Blur
renderGaussian3Blur(quarter1_fbo, quarter2_fbo);
@ -1356,8 +1357,8 @@ void PostProcessing::renderGodRays(scene::ICameraSceneNode * const camnode,
glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
fbo.bind();
renderPassThrough(quarter2_fbo.getRTT()[0], fbo.getWidth(), fbo.getHeight());
in_fbo.bind();
renderPassThrough(quarter2_fbo.getRTT()[0], in_fbo.getWidth(), in_fbo.getHeight());
glDisable(GL_BLEND);
}
@ -1452,7 +1453,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode,
{
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
ScopedGPUTimer Timer(irr_driver->getGPUTimer(Q_GODRAYS));
renderGodRays(camnode, *out_fbo, rtts->getFBO(FBO_QUARTER1), rtts->getFBO(FBO_QUARTER2));
renderGodRays(camnode, *in_fbo, *out_fbo, rtts->getFBO(FBO_QUARTER1), rtts->getFBO(FBO_QUARTER2));
PROFILER_POP_CPU_MARKER();
}

View File

@ -104,6 +104,7 @@ public:
void renderDoF(const FrameBuffer &framebuffer, GLuint color_texture, GLuint depth_stencil_texture);
void renderGodRays(scene::ICameraSceneNode * const camnode,
const FrameBuffer &in_fbo,
const FrameBuffer &out_fbo,
const FrameBuffer &quarter1_fbo,
const FrameBuffer &quarter2_fbo);

View File

@ -31,7 +31,6 @@
#include "graphics/shaders.hpp"
#include "graphics/skybox.hpp"
#include "graphics/spherical_harmonics.hpp"
#include "graphics/stk_scene_manager.hpp"
#include "graphics/texture_manager.hpp"
#include "items/item_manager.hpp"
#include "items/powerup_manager.hpp"
@ -43,8 +42,6 @@
#include <algorithm>
extern std::vector<float> BoundingBoxes; //TODO: replace global variable by something cleaner
// ----------------------------------------------------------------------------
void ShaderBasedRenderer::setRTT(RTT* rtts)
{
@ -357,30 +354,37 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
if (CVS->isDefferedEnabled())
{
if (CVS->isGlobalIlluminationEnabled() && hasShadow)
{
{
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_RH));
m_lighting_passes.renderRadianceHints( m_shadow_matrices,
m_rtts->getRadianceHintFrameBuffer(),
m_rtts->getReflectiveShadowMapFrameBuffer());
}
m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).bind();
glClear(GL_COLOR_BUFFER_BIT);
m_rtts->getFBO(FBO_DIFFUSE).bind();
if (CVS->isGlobalIlluminationEnabled() && hasShadow)
{
ScopedGPUTimer timer(irr_driver->getGPUTimer(Q_GI));
m_lighting_passes.renderGlobalIllumination( m_shadow_matrices,
m_rtts->getRadianceHintFrameBuffer(),
m_rtts->getReflectiveShadowMapFrameBuffer(),
m_rtts->getFBO(FBO_DIFFUSE),
m_rtts->getRenderTarget(RTT_NORMAL_AND_DEPTH),
m_rtts->getDepthStencilTexture());
}
GLuint specular_probe;
if(m_skybox)
}
m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR).bind();
GLuint specular_probe = 0;
if (m_skybox)
{
specular_probe = m_skybox->getSpecularProbe();
}
else
{
specular_probe = 0;
}
m_lighting_passes.renderLights( hasShadow,
m_rtts->getRenderTarget(RTT_NORMAL_AND_DEPTH),
m_rtts->getDepthStencilTexture(),
m_rtts->getShadowFrameBuffer(),
m_rtts->getFBO(FBO_COMBINED_DIFFUSE_SPECULAR),
specular_probe);
}
PROFILER_POP_CPU_MARKER();
@ -469,8 +473,6 @@ void ShaderBasedRenderer::renderScene(scene::ICameraSceneNode * const camnode,
m_rtts->getFBO(FBO_COLORS).bind();
m_lighting_passes.renderGlobalIllumination(m_shadow_matrices,
m_rtts->getRadianceHintFrameBuffer(),
m_rtts->getReflectiveShadowMapFrameBuffer(),
m_rtts->getFBO(FBO_DIFFUSE),
m_rtts->getRenderTarget(RTT_NORMAL_AND_DEPTH),
m_rtts->getDepthStencilTexture());
}
@ -536,24 +538,6 @@ void ShaderBasedRenderer::renderParticles()
// m_scene_manager->drawAll(scene::ESNRP_TRANSPARENT_EFFECT);
} //renderParticles
// ----------------------------------------------------------------------------
void ShaderBasedRenderer::renderBoundingBoxes()
{
Shaders::ColoredLine *line = Shaders::ColoredLine::getInstance();
line->use();
line->bindVertexArray();
line->bindBuffer();
line->setUniforms(irr::video::SColor(255, 255, 0, 0));
const float *tmp = BoundingBoxes.data();
for (unsigned int i = 0; i < BoundingBoxes.size(); i += 1024 * 6)
{
unsigned count = std::min((unsigned)BoundingBoxes.size() - i, (unsigned)1024 * 6);
glBufferSubData(GL_ARRAY_BUFFER, 0, count * sizeof(float), &tmp[i]);
glDrawArrays(GL_LINES, 0, count / 3);
}
} //renderBoundingBoxes
// ----------------------------------------------------------------------------
void ShaderBasedRenderer::debugPhysics()
{
@ -804,9 +788,7 @@ void ShaderBasedRenderer::render(float dt)
{
resetObjectCount();
resetPolyCount();
BoundingBoxes.clear(); //TODO: do not use a global variable
setOverrideMaterial();
addItemsInGlowingList();
@ -858,7 +840,7 @@ void ShaderBasedRenderer::render(float dt)
if (irr_driver->getBoundingBoxesViz())
{
renderBoundingBoxes();
m_draw_calls.renderBoundingBoxes();
}
debugPhysics();

View File

@ -81,7 +81,6 @@ private:
void renderParticles();
void renderBoundingBoxes();
void debugPhysics();
void renderPostProcessing(Camera * const camera);

View File

@ -350,8 +350,7 @@ Shaders::ObjectPass2Shader::ObjectPass2Shader()
{
loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert",
GL_FRAGMENT_SHADER, "object_pass2.frag");
m_color_change_location = glGetUniformLocation(m_program, "color_change");
assignUniforms("ModelMatrix", "TextureMatrix");
assignUniforms("ModelMatrix", "TextureMatrix", "color_change");
assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED,
1, "SpecularMap", ST_NEAREST_FILTERED,
2, "SSAO", ST_BILINEAR_FILTERED,

View File

@ -145,17 +145,11 @@ public:
// ========================================================================
class ObjectPass2Shader : public TextureShader < ObjectPass2Shader, 6,
core::matrix4, core::matrix4 >
core::matrix4, core::matrix4,
core::vector2df >
{
private:
GLint m_color_change_location;
public:
ObjectPass2Shader();
virtual bool changeableColor(float hue = 0.0f, float min_sat = 0.0f) const OVERRIDE
{
glUniform2f(m_color_change_location, hue, min_sat);
return true;
} // changeableColor
}; // ObjectPass2Shader
// ========================================================================

View File

@ -112,7 +112,8 @@ public:
// ----------------------------------------------------------------------------
class ListMatDefault : public MeshList<ListMatDefault, GLMesh *, core::matrix4,
core::matrix4, core::matrix4>
core::matrix4, core::matrix4,
core::vector2df>
{};
// ----------------------------------------------------------------------------
@ -122,7 +123,8 @@ class ListMatAlphaRef : public MeshList<ListMatAlphaRef, GLMesh *, core::matrix4
// ----------------------------------------------------------------------------
class ListMatNormalMap : public MeshList<ListMatNormalMap, GLMesh *, core::matrix4,
core::matrix4, core::matrix4>
core::matrix4, core::matrix4,
core::vector2df>
{};
// ----------------------------------------------------------------------------

View File

@ -449,7 +449,8 @@ void STKMeshSceneNode::render()
getTextureGLuint(mesh.textures[1]),
getTextureGLuint(mesh.textures[7]));
Shaders::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation,
mesh.TextureMatrix);
mesh.TextureMatrix,
core::vector2df(0.0f, 0.0f));
assert(mesh.vao);
glBindVertexArray(mesh.vao);
glDrawElements(ptype, count, itype, 0);

View File

@ -1,63 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014-2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "graphics/stk_scene_manager.hpp"
#include <SViewFrustum.h>
#include <vector>
using namespace irr;
// From irrlicht code
static
bool isBoxInFrontOfPlane(const core::plane3df &plane, const core::vector3df edges[8])
{
for (u32 j = 0; j<8; ++j)
if (plane.classifyPointRelation(edges[j]) != core::ISREL3D_FRONT)
return false;
return true;
}
std::vector<float> BoundingBoxes;
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);
}
bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node)
{
if (!node->getAutomaticCulling())
return false;
const core::matrix4 &trans = node->getAbsoluteTransformation();
const scene::SViewFrustum &frust = *cam->getViewFrustum();
core::vector3df edges[8];
node->getBoundingBox().getEdges(edges);
for (unsigned i = 0; i < 8; i++)
trans.transformVect(edges[i]);
for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i)
if (isBoxInFrontOfPlane(frust.planes[i], edges))
return true;
return false;
}

View File

@ -1,33 +0,0 @@
// SuperTuxKart - a fun racing game with go-kart
// Copyright (C) 2014-2015 SuperTuxKart-Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Not really a scene manager yet but hold algorithm that
// rework scene manager output
#ifndef HEADER_STKSCENEMANAGER_HPP
#define HEADER_STKSCENEMANAGER_HPP
#include <ICameraSceneNode.h>
#include <ISceneNode.h>
#include <vector3d.h>
void addEdge(const irr::core::vector3df &P0, const irr::core::vector3df &P1);
bool isCulledPrecise(const irr::scene::ICameraSceneNode *cam, const irr::scene::ISceneNode *node);
#endif

View File

@ -194,8 +194,10 @@ public:
*/
bool hitKart(const Vec3 &xyz, const AbstractKart *kart=NULL) const
{
Vec3 diff = (xyz - m_xyz);
diff.setY(diff.getY() / 2.0f); // don't be too strict if the kart is a bit above the item
return (m_event_handler!=kart || m_deactive_time <=0) &&
(xyz-m_xyz).length2()<m_distance_2;
diff.length2()<m_distance_2;
} // hitKart
protected:

View File

@ -119,9 +119,9 @@ void ThreeStrikesBattle::reset()
scene::ISceneNode* kart_node = m_karts[n]->getNode();
// FIXME: sorry for this ugly const_cast, irrlicht doesn't seem to allow getting a writable list of children, wtf??
core::list<scene::ISceneNode*>& children = const_cast<core::list<scene::ISceneNode*>&>(kart_node->getChildren());
for (core::list<scene::ISceneNode*>::Iterator it = children.begin(); it != children.end(); it++)
core::list<scene::ISceneNode*>& children = kart_node->getChildren();
for (core::list<scene::ISceneNode*>::Iterator it = children.begin();
it != children.end(); it++)
{
scene::ISceneNode* curr = *it;
@ -295,11 +295,7 @@ void ThreeStrikesBattle::kartHit(const unsigned int kart_id)
}
scene::ISceneNode* kart_node = m_karts[kart_id]->getNode();
// FIXME: sorry for this ugly const_cast, irrlicht doesn't seem to allow
// getting a writable list of children, wtf??
core::list<scene::ISceneNode*>& children =
const_cast<core::list<scene::ISceneNode*>&>(kart_node->getChildren());
core::list<scene::ISceneNode*>& children = kart_node->getChildren();
for (core::list<scene::ISceneNode*>::Iterator it = children.begin();
it != children.end(); it++)
{
@ -608,8 +604,7 @@ void ThreeStrikesBattle::addKartLife(unsigned int id)
updateKartRanks();
scene::ISceneNode* kart_node = m_karts[id]->getNode();
core::list<scene::ISceneNode*>& children =
const_cast<core::list<scene::ISceneNode*>&>(kart_node->getChildren());
core::list<scene::ISceneNode*>& children = kart_node->getChildren();
for (core::list<scene::ISceneNode*>::Iterator it = children.begin();
it != children.end(); it++)
{