Use for_in macro in stkmeshscenenode too.
This commit is contained in:
@@ -98,9 +98,9 @@ void STKMeshSceneNode::cleanGLMeshes()
|
||||
}
|
||||
GLmeshes.clear();
|
||||
for (unsigned i = 0; i < FPSM_COUNT; i++)
|
||||
GeometricMesh[i].clear();
|
||||
GeometricMesh[i].clearWithoutDeleting();
|
||||
for (unsigned i = 0; i < SM_COUNT; i++)
|
||||
ShadedMesh[i].clear();
|
||||
ShadedMesh[i].clearWithoutDeleting();
|
||||
}
|
||||
|
||||
void STKMeshSceneNode::setMesh(irr::scene::IMesh* mesh)
|
||||
@@ -343,32 +343,32 @@ void STKMeshSceneNode::render()
|
||||
TransposeInverseModelView = computeTIMV(AbsoluteTransformation);
|
||||
core::matrix4 invmodel;
|
||||
AbsoluteTransformation.getInverse(invmodel);
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||
GLMesh* mesh;
|
||||
for_in(mesh, GeometricMesh[FPSM_DEFAULT])
|
||||
{
|
||||
|
||||
GroupedFPSM<FPSM_DEFAULT>::MeshSet.push_back(GeometricMesh[FPSM_DEFAULT][i]);
|
||||
GroupedFPSM<FPSM_DEFAULT>::MeshSet.push_back(mesh);
|
||||
GroupedFPSM<FPSM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_DEFAULT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||
for_in(mesh, GeometricMesh[FPSM_ALPHA_REF_TEXTURE])
|
||||
{
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MeshSet.push_back(GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MeshSet.push_back(mesh);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_NORMAL_MAP].size(); i++)
|
||||
for_in(mesh, GeometricMesh[FPSM_NORMAL_MAP])
|
||||
{
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::MeshSet.push_back(GeometricMesh[FPSM_NORMAL_MAP][i]);
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::MeshSet.push_back(mesh);
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedFPSM<FPSM_NORMAL_MAP>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
if (!GeometricMesh[FPSM_GRASS].empty())
|
||||
glUseProgram(MeshShader::GrassPass1Shader::Program);
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_GRASS].size(); i++)
|
||||
drawSolidPass1(*GeometricMesh[FPSM_GRASS][i], FPSM_GRASS);
|
||||
for_in(mesh, GeometricMesh[FPSM_GRASS])
|
||||
drawSolidPass1(*mesh, FPSM_GRASS);
|
||||
|
||||
if (reload_each_frame)
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -383,57 +383,58 @@ void STKMeshSceneNode::render()
|
||||
core::matrix4 invmodel;
|
||||
AbsoluteTransformation.getInverse(invmodel);
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
|
||||
GLMesh* mesh;
|
||||
for_in(mesh, ShadedMesh[SM_DEFAULT])
|
||||
{
|
||||
GroupedSM<SM_DEFAULT>::MeshSet.push_back(ShadedMesh[SM_DEFAULT][i]);
|
||||
GroupedSM<SM_DEFAULT>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_DEFAULT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_DEFAULT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
|
||||
for_in(mesh, ShadedMesh[SM_ALPHA_REF_TEXTURE])
|
||||
{
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MeshSet.push_back(ShadedMesh[SM_ALPHA_REF_TEXTURE][i]);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_ALPHA_REF_TEXTURE>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
|
||||
for_in(mesh, ShadedMesh[SM_RIMLIT])
|
||||
{
|
||||
GroupedSM<SM_RIMLIT>::MeshSet.push_back(ShadedMesh[SM_RIMLIT][i]);
|
||||
GroupedSM<SM_RIMLIT>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_RIMLIT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_RIMLIT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_SPHEREMAP].size(); i++)
|
||||
for_in(mesh, ShadedMesh[SM_SPHEREMAP])
|
||||
{
|
||||
GroupedSM<SM_SPHEREMAP>::MeshSet.push_back(ShadedMesh[SM_SPHEREMAP][i]);
|
||||
GroupedSM<SM_SPHEREMAP>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_SPHEREMAP>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_SPHEREMAP>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_SPLATTING])
|
||||
for_in(mesh, ShadedMesh[SM_SPLATTING])
|
||||
{
|
||||
GroupedSM<SM_SPLATTING>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_SPLATTING>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_SPLATTING>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_UNLIT])
|
||||
for_in(mesh, ShadedMesh[SM_UNLIT])
|
||||
{
|
||||
GroupedSM<SM_UNLIT>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_UNLIT>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_UNLIT>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_DETAILS])
|
||||
for_in(mesh, ShadedMesh[SM_DETAILS])
|
||||
{
|
||||
GroupedSM<SM_DETAILS>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_DETAILS>::MVPSet.push_back(AbsoluteTransformation);
|
||||
GroupedSM<SM_DETAILS>::TIMVSet.push_back(invmodel);
|
||||
}
|
||||
|
||||
for (GLMesh *mesh : ShadedMesh[SM_UNTEXTURED])
|
||||
for_in(mesh, ShadedMesh[SM_UNTEXTURED])
|
||||
{
|
||||
GroupedSM<SM_UNTEXTURED>::MeshSet.push_back(mesh);
|
||||
GroupedSM<SM_UNTEXTURED>::MVPSet.push_back(AbsoluteTransformation);
|
||||
@@ -442,13 +443,13 @@ void STKMeshSceneNode::render()
|
||||
|
||||
if (!ShadedMesh[SM_GRASS].empty())
|
||||
glUseProgram(MeshShader::GrassPass2Shader::Program);
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_GRASS].size(); i++)
|
||||
drawSolidPass2(*ShadedMesh[SM_GRASS][i], SM_GRASS);
|
||||
for_in(mesh, ShadedMesh[SM_GRASS])
|
||||
drawSolidPass2(*mesh, SM_GRASS);
|
||||
|
||||
if (!ShadedMesh[SM_CAUSTICS].empty())
|
||||
glUseProgram(MeshShader::CausticsShader::Program);
|
||||
for (unsigned i = 0; i < ShadedMesh[SM_CAUSTICS].size(); i++)
|
||||
drawSolidPass2(*ShadedMesh[SM_CAUSTICS][i], SM_CAUSTICS);
|
||||
for_in(mesh, ShadedMesh[SM_CAUSTICS])
|
||||
drawSolidPass2(*mesh, SM_CAUSTICS);
|
||||
|
||||
if (reload_each_frame)
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -460,15 +461,16 @@ void STKMeshSceneNode::render()
|
||||
if (reload_each_frame)
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
GLMesh* mesh;
|
||||
if (!GeometricMesh[FPSM_DEFAULT].empty())
|
||||
glUseProgram(MeshShader::ShadowShader::Program);
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
|
||||
drawShadow(*GeometricMesh[FPSM_DEFAULT][i], AbsoluteTransformation);
|
||||
for_in(mesh, GeometricMesh[FPSM_DEFAULT])
|
||||
drawShadow(*mesh, AbsoluteTransformation);
|
||||
|
||||
if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty())
|
||||
glUseProgram(MeshShader::RefShadowShader::Program);
|
||||
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
|
||||
drawShadowRef(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i], AbsoluteTransformation);
|
||||
for_in(mesh, GeometricMesh[FPSM_ALPHA_REF_TEXTURE])
|
||||
drawShadowRef(*mesh, AbsoluteTransformation);
|
||||
|
||||
if (reload_each_frame)
|
||||
glEnable(GL_CULL_FACE);
|
||||
@@ -491,24 +493,25 @@ void STKMeshSceneNode::render()
|
||||
{
|
||||
ModelViewProjectionMatrix = computeMVP(AbsoluteTransformation);
|
||||
|
||||
GLMesh* mesh;
|
||||
if (!TransparentMesh[TM_BUBBLE].empty())
|
||||
glUseProgram(MeshShader::BubbleShader::Program);
|
||||
for (unsigned i = 0; i < TransparentMesh[TM_BUBBLE].size(); i++)
|
||||
drawBubble(*TransparentMesh[TM_BUBBLE][i], ModelViewProjectionMatrix);
|
||||
for_in(mesh, TransparentMesh[TM_BUBBLE])
|
||||
drawBubble(*mesh, ModelViewProjectionMatrix);
|
||||
|
||||
if (World::getWorld()->getTrack()->isFogEnabled())
|
||||
{
|
||||
if (!TransparentMesh[TM_DEFAULT].empty())
|
||||
glUseProgram(MeshShader::TransparentFogShader::Program);
|
||||
for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++)
|
||||
drawTransparentFogObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix);
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
drawTransparentFogObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!TransparentMesh[TM_DEFAULT].empty())
|
||||
glUseProgram(MeshShader::TransparentShader::Program);
|
||||
for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++)
|
||||
drawTransparentObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix);
|
||||
for_in(mesh, TransparentMesh[TM_DEFAULT])
|
||||
drawTransparentObject(*mesh, ModelViewProjectionMatrix, (*mesh).TextureMatrix);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
#define STKMESHSCENENODE_H
|
||||
|
||||
#include "stkmesh.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
class STKMeshSceneNode : public irr::scene::CMeshSceneNode
|
||||
{
|
||||
protected:
|
||||
std::vector<GLMesh *> GeometricMesh[FPSM_COUNT];
|
||||
std::vector<GLMesh *> ShadedMesh[SM_COUNT];
|
||||
std::vector<GLMesh *> TransparentMesh[TM_COUNT];
|
||||
PtrVector<GLMesh, REF> GeometricMesh[FPSM_COUNT];
|
||||
PtrVector<GLMesh, REF> ShadedMesh[SM_COUNT];
|
||||
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];
|
||||
std::vector<GLMesh> GLmeshes;
|
||||
core::matrix4 ModelViewProjectionMatrix, TransposeInverseModelView;
|
||||
core::vector3df windDir;
|
||||
|
||||
Reference in New Issue
Block a user