Remove vector int in RenderInfo
This commit is contained in:
parent
8408a7c158
commit
1d6c7fa60f
@ -29,16 +29,3 @@ RenderInfo::RenderInfo(float hue, bool transparent)
|
||||
m_hue = hue;
|
||||
m_transparent = transparent;
|
||||
} // RenderInfo
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void RenderInfo::setColorizableParts(irr::scene::IMesh* m)
|
||||
{
|
||||
for (int i = 0; i < int(m->getMeshBufferCount()); i++)
|
||||
{
|
||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
||||
Material* material = material_manager->getMaterialFor(mb
|
||||
->getMaterial().getTexture(0), mb);
|
||||
if (material->isColorizable())
|
||||
m_colorizable_parts.push_back(i);
|
||||
}
|
||||
} // setColorizableParts
|
||||
|
@ -21,9 +21,6 @@
|
||||
|
||||
#include "utils/leak_check.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene { class IMesh; }
|
||||
@ -48,8 +45,6 @@ private:
|
||||
|
||||
bool m_transparent;
|
||||
|
||||
std::vector<int> m_colorizable_parts;
|
||||
|
||||
public:
|
||||
LEAK_CHECK();
|
||||
// ------------------------------------------------------------------------
|
||||
@ -57,8 +52,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
~RenderInfo() {}
|
||||
// ------------------------------------------------------------------------
|
||||
void setColorizableParts(irr::scene::IMesh* m);
|
||||
// ------------------------------------------------------------------------
|
||||
void setHue(float hue) { m_hue = hue; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setTransparent(bool transparent) { m_transparent = transparent; }
|
||||
@ -67,13 +60,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
bool isTransparent() const { return m_transparent; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isColorizable(int mesh_buffer_index) const
|
||||
{
|
||||
return m_colorizable_parts.empty() ||
|
||||
std::find(m_colorizable_parts.begin(), m_colorizable_parts.end(),
|
||||
mesh_buffer_index) != m_colorizable_parts.end();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void setKartModelRenderInfo(KartRenderType krt)
|
||||
{
|
||||
setHue(krt == RenderInfo::KRT_BLUE ? 0.66f :
|
||||
|
@ -107,7 +107,10 @@ void STKAnimatedMesh::updateNoGL()
|
||||
if (!m_all_parts_colorized && mb && m_mesh_render_info)
|
||||
{
|
||||
// Test if material is affected by hue change
|
||||
affected = m_mesh_render_info->isColorizable(i);
|
||||
Material* m = material_manager->getMaterialFor(mb
|
||||
->getMaterial().getTexture(0), mb);
|
||||
if (m->isColorizable())
|
||||
affected = true;
|
||||
}
|
||||
|
||||
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name,
|
||||
|
@ -83,8 +83,11 @@ void STKMeshSceneNode::createGLMeshes(RenderInfo* render_info, bool all_parts_co
|
||||
bool affected = false;
|
||||
if (!all_parts_colorized && mb && render_info)
|
||||
{
|
||||
// Test if material is affected by hue change
|
||||
affected = render_info->isColorizable(i);
|
||||
// Test if material is affected by hue change
|
||||
Material* m = material_manager->getMaterialFor(mb
|
||||
->getMaterial().getTexture(0), mb);
|
||||
if (m->isColorizable())
|
||||
affected = true;
|
||||
}
|
||||
|
||||
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name,
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
GLuint getTextureGLuint(irr::video::ITexture *tex)
|
||||
{
|
||||
assert(tex != NULL);
|
||||
#if defined(USE_GLES2)
|
||||
return static_cast<irr::video::COGLES2Texture*>(tex)->getOpenGLTextureName();
|
||||
#else
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/lod_node.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/mesh_tools.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
@ -140,7 +142,7 @@ KartModel::KartModel(bool is_master)
|
||||
m_current_animation = AF_DEFAULT;
|
||||
m_play_non_loop = false;
|
||||
m_krt = RenderInfo::KRT_DEFAULT;
|
||||
m_render_info = RenderInfo();
|
||||
m_support_colorization = false;
|
||||
} // KartModel
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -294,21 +296,21 @@ KartModel* KartModel::makeCopy(RenderInfo::KartRenderType krt)
|
||||
// just in case.
|
||||
assert(m_is_master);
|
||||
assert(!m_animated_node);
|
||||
KartModel *km = new KartModel(/*is master*/ false);
|
||||
km->m_kart_width = m_kart_width;
|
||||
km->m_kart_length = m_kart_length;
|
||||
km->m_kart_height = m_kart_height;
|
||||
km->m_kart_highest_point= m_kart_highest_point;
|
||||
km->m_kart_lowest_point = m_kart_lowest_point;
|
||||
km->m_mesh = irr_driver->copyAnimatedMesh(m_mesh);
|
||||
km->m_model_filename = m_model_filename;
|
||||
km->m_animation_speed = m_animation_speed;
|
||||
km->m_current_animation = AF_DEFAULT;
|
||||
km->m_animated_node = NULL;
|
||||
km->m_hat_offset = m_hat_offset;
|
||||
km->m_hat_name = m_hat_name;
|
||||
km->m_krt = krt;
|
||||
km->m_render_info = m_render_info;
|
||||
KartModel *km = new KartModel(/*is master*/ false);
|
||||
km->m_kart_width = m_kart_width;
|
||||
km->m_kart_length = m_kart_length;
|
||||
km->m_kart_height = m_kart_height;
|
||||
km->m_kart_highest_point = m_kart_highest_point;
|
||||
km->m_kart_lowest_point = m_kart_lowest_point;
|
||||
km->m_mesh = irr_driver->copyAnimatedMesh(m_mesh);
|
||||
km->m_model_filename = m_model_filename;
|
||||
km->m_animation_speed = m_animation_speed;
|
||||
km->m_current_animation = AF_DEFAULT;
|
||||
km->m_animated_node = NULL;
|
||||
km->m_hat_offset = m_hat_offset;
|
||||
km->m_hat_name = m_hat_name;
|
||||
km->m_krt = krt;
|
||||
km->m_support_colorization = m_support_colorization;
|
||||
|
||||
km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0];
|
||||
km->m_nitro_emitter_position[1] = m_nitro_emitter_position[1];
|
||||
@ -520,8 +522,15 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
|
||||
MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]),
|
||||
&kart_min, &kart_max);
|
||||
|
||||
// Enable colorization for karts later when attachModel
|
||||
m_render_info.setColorizableParts(m_mesh);
|
||||
// Test if kart model support colorization
|
||||
for (int i = 0; i < int(m_mesh->getMeshBufferCount()); i++)
|
||||
{
|
||||
scene::IMeshBuffer* mb = m_mesh->getMeshBuffer(i);
|
||||
Material* material = material_manager->getMaterialFor(mb
|
||||
->getMaterial().getTexture(0), mb);
|
||||
m_support_colorization =
|
||||
m_support_colorization || material->isColorizable();
|
||||
}
|
||||
|
||||
#undef MOVE_KART_MESHES
|
||||
#ifdef MOVE_KART_MESHES
|
||||
|
@ -235,6 +235,8 @@ private:
|
||||
|
||||
RenderInfo m_render_info;
|
||||
|
||||
bool m_support_colorization;
|
||||
|
||||
public:
|
||||
KartModel(bool is_master);
|
||||
~KartModel();
|
||||
@ -335,9 +337,19 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
core::vector3df getHatOffset() { return m_hat_offset; }
|
||||
// ------------------------------------------------------------------------
|
||||
RenderInfo* getRenderInfo() { return &m_render_info; }
|
||||
RenderInfo* getRenderInfo()
|
||||
{
|
||||
return m_support_colorization || m_krt == RenderInfo::KRT_TRANSPARENT ?
|
||||
&m_render_info : NULL;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
const RenderInfo* getRenderInfo() const { return &m_render_info; }
|
||||
const RenderInfo* getRenderInfo() const
|
||||
{
|
||||
return m_support_colorization || m_krt == RenderInfo::KRT_TRANSPARENT ?
|
||||
&m_render_info : NULL;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
bool supportColorization() const { return m_support_colorization; }
|
||||
|
||||
}; // KartModel
|
||||
#endif
|
||||
|
@ -305,9 +305,6 @@ void SoccerWorld::countdownReachedZero()
|
||||
//-----------------------------------------------------------------------------
|
||||
void SoccerWorld::initKartList()
|
||||
{
|
||||
// Color of karts can be changed using shaders
|
||||
if (CVS->isGLSL()) return;
|
||||
|
||||
const unsigned int kart_amount = (unsigned int)m_karts.size();
|
||||
|
||||
//Loading the indicator textures
|
||||
@ -317,10 +314,15 @@ void SoccerWorld::initKartList()
|
||||
irr_driver->getTexture(FileManager::GUI, "soccer_player_blue.png");
|
||||
|
||||
//Assigning indicators
|
||||
for(unsigned int i=0; i<kart_amount; i++)
|
||||
for(unsigned int i = 0; i < kart_amount; i++)
|
||||
{
|
||||
scene::ISceneNode *arrow_node;
|
||||
float arrow_pos_height = m_karts[i]->getKartModel()->getHeight()+0.5f;
|
||||
scene::ISceneNode *arrow_node = NULL;
|
||||
|
||||
KartModel* km = m_karts[i]->getKartModel();
|
||||
// Color of karts can be changed using shaders if the model supports
|
||||
if (km->supportColorization() && CVS->isGLSL()) continue;
|
||||
|
||||
float arrow_pos_height = km->getHeight() + 0.5f;
|
||||
SoccerTeam team = getKartTeam(i);
|
||||
|
||||
arrow_node = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3f,
|
||||
|
@ -146,12 +146,13 @@ void SoccerSetupScreen::beforeAddingWidget()
|
||||
(i&1 ? SOCCER_TEAM_BLUE : SOCCER_TEAM_RED));
|
||||
|
||||
// addModel requires loading the RenderInfo first
|
||||
kart_view->getModelViewRenderInfo().setRenderInfo
|
||||
(kart_model.getRenderInfo());
|
||||
|
||||
kart_view->getModelViewRenderInfo().setKartModelRenderInfo
|
||||
(info.team == SOCCER_TEAM_BLUE ?
|
||||
RenderInfo::KRT_BLUE : RenderInfo::KRT_RED);
|
||||
info.support_colorization = kart_model.supportColorization();
|
||||
if (info.support_colorization)
|
||||
{
|
||||
kart_view->getModelViewRenderInfo().setKartModelRenderInfo
|
||||
(info.team == SOCCER_TEAM_BLUE ?
|
||||
RenderInfo::KRT_BLUE : RenderInfo::KRT_RED);
|
||||
}
|
||||
|
||||
// Add the kart model (including wheels and speed weight objects)
|
||||
kart_view->addModel( kart_model.getModel(), Vec3(0,0,0),
|
||||
@ -291,8 +292,11 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
||||
team_switch = SOCCER_TEAM_RED;
|
||||
|
||||
// Change the kart color
|
||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||
.setKartModelRenderInfo(RenderInfo::KRT_RED);
|
||||
if (m_kart_view_info[playerId].support_colorization)
|
||||
{
|
||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||
.setKartModelRenderInfo(RenderInfo::KRT_RED);
|
||||
}
|
||||
|
||||
for(int i=0 ; i < nb_players ; i++)
|
||||
{
|
||||
@ -308,8 +312,11 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
||||
team_switch = SOCCER_TEAM_BLUE;
|
||||
|
||||
// Change the kart color
|
||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||
.setKartModelRenderInfo(RenderInfo::KRT_BLUE);
|
||||
if (m_kart_view_info[playerId].support_colorization)
|
||||
{
|
||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||
.setKartModelRenderInfo(RenderInfo::KRT_BLUE);
|
||||
}
|
||||
|
||||
for(int i=0 ; i < nb_players ; i++)
|
||||
{
|
||||
|
@ -28,7 +28,8 @@ namespace GUIEngine { class Widget; class LabelWidget; class ModelViewWidget; }
|
||||
* \brief Screen with soccer setup options
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class SoccerSetupScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<SoccerSetupScreen>
|
||||
class SoccerSetupScreen : public GUIEngine::Screen,
|
||||
public GUIEngine::ScreenSingleton<SoccerSetupScreen>
|
||||
{
|
||||
friend class GUIEngine::ScreenSingleton<SoccerSetupScreen>;
|
||||
|
||||
@ -38,10 +39,12 @@ class SoccerSetupScreen : public GUIEngine::Screen, public GUIEngine::ScreenSing
|
||||
{
|
||||
GUIEngine::ModelViewWidget* view;
|
||||
bool confirmed;
|
||||
bool support_colorization;
|
||||
SoccerTeam team;
|
||||
RenderInfo render_info;
|
||||
|
||||
KartViewInfo() : view(), confirmed(false), team(SOCCER_TEAM_NONE) {}
|
||||
KartViewInfo() : view(), confirmed(false), support_colorization(false),
|
||||
team(SOCCER_TEAM_NONE) {}
|
||||
};
|
||||
|
||||
AlignedArray<KartViewInfo> m_kart_view_info;
|
||||
|
Loading…
Reference in New Issue
Block a user