Merge remote-tracking branch 'origin/master' into threaded_tex_loader

This commit is contained in:
Benau 2017-03-11 13:55:18 +08:00
commit ab673fc03b
12 changed files with 134 additions and 70 deletions

View File

@ -37,7 +37,7 @@ vec4 renderSolid()
if(uTextureUsage0) if(uTextureUsage0)
Color *= texture2D(uTextureUnit0, varTexCoord0); Color *= texture2D(uTextureUnit0, varTexCoord0);
Color.a = 1.0; //Color.a = 1.0;
return Color; return Color;
} }

View File

@ -67,15 +67,12 @@ void COGLES2FixedPipelineRenderer::OnSetMaterial(const video::SMaterial& materia
} }
else if (Blending) else if (Blending)
{ {
//E_BLEND_FACTOR srcFact,dstFact; E_BLEND_FACTOR srcFact,dstFact;
//E_MODULATE_FUNC modulate; E_MODULATE_FUNC modulate;
//u32 alphaSource; u32 alphaSource;
//unpack_textureBlendFunc(srcFact, dstFact, modulate, alphaSource, material.MaterialTypeParam); unpack_textureBlendFunc(srcFact, dstFact, modulate, alphaSource, material.MaterialTypeParam);
//Driver->getBridgeCalls()->setBlendFunc(Driver->getGLBlend(srcFact), Driver->getGLBlend(dstFact)); Driver->getBridgeCalls()->setBlendFunc(Driver->getGLBlend(srcFact), Driver->getGLBlend(dstFact));
//Driver->getBridgeCalls()->setBlend(true);
Driver->getBridgeCalls()->setBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
Driver->getBridgeCalls()->setBlend(true); Driver->getBridgeCalls()->setBlend(true);
} }
else else

View File

@ -1653,7 +1653,12 @@ void IrrDriver::onUnloadWorld()
void IrrDriver::setAmbientLight(const video::SColorf &light, bool force_SH_computation) void IrrDriver::setAmbientLight(const video::SColorf &light, bool force_SH_computation)
{ {
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
m_scene_manager->setAmbientLight(light); video::SColorf color = light;
color.r = powf(color.r, 1.0f / 2.2f);
color.g = powf(color.g, 1.0f / 2.2f);
color.b = powf(color.b, 1.0f / 2.2f);
m_scene_manager->setAmbientLight(color);
m_renderer->setAmbientLight(light, force_SH_computation); m_renderer->setAmbientLight(light, force_SH_computation);
#endif #endif
} // setAmbientLight } // setAmbientLight
@ -2060,7 +2065,7 @@ scene::ISceneNode *IrrDriver::addLight(const core::vector3df &pos,
{ {
scene::ILightSceneNode* light = m_scene_manager scene::ILightSceneNode* light = m_scene_manager
->addLightSceneNode(m_scene_manager->getRootSceneNode(), ->addLightSceneNode(m_scene_manager->getRootSceneNode(),
pos, video::SColorf(1.0f, r, g, b)); pos, video::SColorf(r, g, b, 1.0f));
light->setRadius(radius); light->setRadius(radius);
return light; return light;
} }

View File

@ -72,7 +72,19 @@ Material::Material(const XMLNode *node, bool deprecated)
if (relativePath.size() == 0) if (relativePath.size() == 0)
Log::warn("Material", "Cannot determine texture full path : <%s>", m_texname.c_str()); Log::warn("Material", "Cannot determine texture full path : <%s>", m_texname.c_str());
else else
m_full_path = file_manager->getFileSystem()->getAbsolutePath(relativePath.c_str()).c_str(); m_full_path = m_original_full_path = file_manager->getFileSystem()->getAbsolutePath(relativePath.c_str()).c_str();
core::stringc texfname(m_texname.c_str());
texfname.make_lower();
m_texname = texfname.c_str();
if (m_full_path.size() > 0)
{
core::stringc texfname2(m_full_path.c_str());
texfname2.make_lower();
m_full_path = texfname2.c_str();
}
init(); init();
bool b = false; bool b = false;
@ -423,15 +435,23 @@ Material::Material(const std::string& fname, bool is_full_path,
if (is_full_path) if (is_full_path)
{ {
m_texname = StringUtils::getBasename(fname); m_texname = StringUtils::getBasename(fname);
m_full_path = fname; m_full_path = m_original_full_path = fname;
} }
else else
{ {
m_texname = fname; m_texname = fname;
m_full_path = file_manager->getFileSystem()->getAbsolutePath( m_full_path = m_original_full_path = file_manager->getFileSystem()->getAbsolutePath(
file_manager->searchTexture(m_texname).c_str()).c_str(); file_manager->searchTexture(m_texname).c_str()).c_str();
} }
core::stringc texfname(m_texname.c_str());
texfname.make_lower();
m_texname = texfname.c_str();
core::stringc texfname2(m_full_path.c_str());
texfname2.make_lower();
m_full_path = texfname2.c_str();
m_complain_if_not_found = complain_if_not_found; m_complain_if_not_found = complain_if_not_found;
if (load_texture) if (load_texture)
@ -507,7 +527,7 @@ void Material::install(bool srgb, bool premul_alpha)
else else
{ {
m_texture = STKTexManager::getInstance()->getTexture m_texture = STKTexManager::getInstance()->getTexture
(m_full_path, srgb, premul_alpha, false/*set_material*/, (m_original_full_path, srgb, premul_alpha, false/*set_material*/,
srgb/*mesh_tex*/); srgb/*mesh_tex*/);
} }
@ -516,6 +536,10 @@ void Material::install(bool srgb, bool premul_alpha)
// now set the name to the basename, so that all tests work as expected // now set the name to the basename, so that all tests work as expected
m_texname = StringUtils::getBasename(m_texname); m_texname = StringUtils::getBasename(m_texname);
core::stringc texfname(m_texname.c_str());
texfname.make_lower();
m_texname = texfname.c_str();
m_texture->grab(); m_texture->grab();
} // install } // install

View File

@ -91,6 +91,8 @@ private:
std::string m_texname; std::string m_texname;
std::string m_full_path; std::string m_full_path;
std::string m_original_full_path;
/** Name of a special sfx to play when a kart is on this terrain, or /** Name of a special sfx to play when a kart is on this terrain, or
* "" if no special sfx exists. */ * "" if no special sfx exists. */

View File

@ -80,17 +80,14 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t,
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Material* MaterialManager::getMaterialFor(video::ITexture* t) Material* MaterialManager::getMaterialFor(video::ITexture* t)
{ {
core::stringc img_path = core::stringc(t->getName()); const io::path& img_path = t->getName().getInternalName();
img_path.make_lower();
if (!img_path.empty() && (img_path.findFirst('/') != -1 || img_path.findFirst('\\') != -1)) if (!img_path.empty() && (img_path.findFirst('/') != -1 || img_path.findFirst('\\') != -1))
{ {
// Search backward so that temporary (track) textures are found first // Search backward so that temporary (track) textures are found first
for (int i = (int)m_materials.size() - 1; i >= 0; i--) for (int i = (int)m_materials.size() - 1; i >= 0; i--)
{ {
core::stringc fullpath = core::stringc(m_materials[i]->getTexFullPath().c_str()); if (m_materials[i]->getTexFullPath() == img_path.c_str())
fullpath.make_lower();
if (fullpath == img_path.c_str())
{ {
return m_materials[i]; return m_materials[i];
} }
@ -103,9 +100,7 @@ Material* MaterialManager::getMaterialFor(video::ITexture* t)
for (int i = (int)m_materials.size() - 1; i >= 0; i--) for (int i = (int)m_materials.size() - 1; i >= 0; i--)
{ {
core::stringc texfname(m_materials[i]->getTexFname().c_str()); if (m_materials[i]->getTexFname() == image.c_str())
texfname.make_lower();
if (texfname == image)
{ {
return m_materials[i]; return m_materials[i];
} }
@ -361,9 +356,7 @@ Material *MaterialManager::getMaterial(const std::string& fname,
// Search backward so that temporary (track) textures are found first // Search backward so that temporary (track) textures are found first
for (int i = (int)m_materials.size()-1; i>=0; i-- ) for (int i = (int)m_materials.size()-1; i>=0; i-- )
{ {
core::stringc fname(m_materials[i]->getTexFname().c_str()); if (m_materials[i]->getTexFname() == basename_lower.c_str())
fname.make_lower();
if (fname == basename_lower)
return m_materials[i]; return m_materials[i];
} }

View File

@ -470,8 +470,12 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
if (m_is_glsl) if (m_is_glsl)
{ {
bool additive = (type->getMaterial()->getShaderType() == Material::SHADERTYPE_ADDITIVE); Material* material = type->getMaterial();
static_cast<ParticleSystemProxy *>(m_node)->setAlphaAdditive(additive); if (material != nullptr)
{
bool additive = (material->getShaderType() == Material::SHADERTYPE_ADDITIVE);
static_cast<ParticleSystemProxy *>(m_node)->setAlphaAdditive(additive);
}
} }
} }

View File

@ -130,6 +130,10 @@ ParticleKind::ParticleKind(const std::string &file)
{ {
material->get("file", &m_material_file); material->get("file", &m_material_file);
core::stringc tmp(m_material_file.c_str());
tmp.make_lower();
m_material_file = tmp.c_str();
if (m_material_file.size() == 0) if (m_material_file.size() == 0)
{ {
delete xml; delete xml;
@ -257,7 +261,7 @@ Material* ParticleKind::getMaterial() const
if (material_manager->hasMaterial(m_material_file)) if (material_manager->hasMaterial(m_material_file))
{ {
Material* material = material_manager->getMaterial(m_material_file); Material* material = material_manager->getMaterial(m_material_file);
if (material->getTexture(true/*srgb*/, true/*premul_alpha*/) == NULL) if (material == NULL || material->getTexture(true/*srgb*/, true/*premul_alpha*/) == NULL)
{ {
throw std::runtime_error("[ParticleKind] Cannot locate file " + m_material_file); throw std::runtime_error("[ParticleKind] Cannot locate file " + m_material_file);
} }

View File

@ -273,17 +273,17 @@ KartModel::~KartModel()
for (size_t i = 0; i < m_headlight_objects.size(); i++) for (size_t i = 0; i < m_headlight_objects.size(); i++)
{ {
HeadlightObject& obj = m_headlight_objects[i]; HeadlightObject& obj = m_headlight_objects[i];
obj.m_node = NULL; obj.setNode(NULL);
if (obj.m_node) if (obj.getNode())
{ {
// Master KartModels should never have a speed weighted object attached. // Master KartModels should never have a headlight attached.
assert(!m_is_master); assert(!m_is_master);
obj.m_node->drop(); obj.getNode()->drop();
} }
if (m_is_master && obj.m_model) if (m_is_master && obj.getModel())
{ {
irr_driver->dropAllTextures(obj.m_model); irr_driver->dropAllTextures(obj.getModel());
irr_driver->removeMeshFromCache(obj.m_model); irr_driver->removeMeshFromCache(obj.getModel());
} }
} }
@ -368,8 +368,8 @@ KartModel* KartModel::makeCopy(KartRenderType krt)
km->m_headlight_objects.resize(m_headlight_objects.size()); km->m_headlight_objects.resize(m_headlight_objects.size());
for (size_t i = 0; i<m_headlight_objects.size(); i++) for (size_t i = 0; i<m_headlight_objects.size(); i++)
{ {
// Master should not have any speed weighted nodes. // Master should not have any headlight nodes.
assert(!m_headlight_objects[i].m_node); assert(!m_headlight_objects[i].getNode());
km->m_headlight_objects[i] = m_headlight_objects[i]; km->m_headlight_objects[i] = m_headlight_objects[i];
} }
@ -448,8 +448,8 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
for (size_t i = 0; i<m_headlight_objects.size(); i++) for (size_t i = 0; i<m_headlight_objects.size(); i++)
{ {
if (!m_headlight_objects[i].m_node) continue; if (!m_headlight_objects[i].getNode()) continue;
m_headlight_objects[i].m_node->setParent(lod_node); m_headlight_objects[i].getNode()->setParent(lod_node);
} }
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
@ -530,20 +530,23 @@ scene::ISceneNode* KartModel::attachModel(bool animated_models, bool always_anim
} }
} }
for (unsigned i = 0; i < m_headlight_objects.size(); i++) for (unsigned int i = 0; i < m_headlight_objects.size(); i++)
{ {
HeadlightObject& obj = m_headlight_objects[i]; HeadlightObject& obj = m_headlight_objects[i];
obj.m_node = NULL; obj.setNode(NULL);
if (obj.m_model) if (obj.getModel())
{ {
obj.m_node = irr_driver->addMesh(obj.m_model, "kart_headlight", node, getRenderInfo()); scene::ISceneNode *new_node =
obj.m_node->grab(); irr_driver->addMesh(obj.getModel(), "kart_headlight",
obj.m_node->setPosition(obj.getPosition()); node, getRenderInfo() );
new_node->grab();
obj.setNode(new_node);
Track* track = Track::getCurrentTrack(); Track* track = Track::getCurrentTrack();
if (track == NULL || track->getIsDuringDay()) if (track == NULL || track->getIsDuringDay())
obj.m_node->setVisible(false); obj.getNode()->setVisible(false);
} }
} }
@ -642,12 +645,12 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
kart_max.max(obj_max); kart_max.max(obj_max);
} }
for (unsigned i = 0; i < m_headlight_objects.size(); i++) for (unsigned int i = 0; i < m_headlight_objects.size(); i++)
{ {
HeadlightObject& obj = m_headlight_objects[i]; HeadlightObject& obj = m_headlight_objects[i];
std::string full_name = kart_properties.getKartDir() + obj.getFilename(); std::string full_name = kart_properties.getKartDir() + obj.getFilename();
obj.m_model = irr_driver->getMesh(full_name); obj.setModel(irr_driver->getMesh(full_name));
irr_driver->grabAllTextures(obj.m_model); irr_driver->grabAllTextures(obj.getModel());
} }
Vec3 size = kart_max-kart_min; Vec3 size = kart_max-kart_min;
@ -722,7 +725,8 @@ void KartModel::loadNitroEmitterInfo(const XMLNode &node,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Loads a single speed weighted node. */ /** Loads a single speed weighted node. */
void KartModel::loadSpeedWeightedInfo(const XMLNode* speed_weighted_node, const SpeedWeightedObject::Properties& fallback_properties) void KartModel::loadSpeedWeightedInfo(const XMLNode* speed_weighted_node,
const SpeedWeightedObject::Properties& fallback_properties)
{ {
SpeedWeightedObject obj; SpeedWeightedObject obj;
obj.m_properties = fallback_properties; obj.m_properties = fallback_properties;
@ -778,7 +782,7 @@ void KartModel::loadHeadlights(const XMLNode &node)
Log::warn("KartModel", "Unknown XML node in the headlights section"); Log::warn("KartModel", "Unknown XML node in the headlights section");
} }
} }
} } // loadHeadlights
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/** Resets the kart model. It stops animation from being played and resets /** Resets the kart model. It stops animation from being played and resets

View File

@ -84,33 +84,64 @@ struct SpeedWeightedObject
}; };
typedef std::vector<SpeedWeightedObject> SpeedWeightedObjectList; typedef std::vector<SpeedWeightedObject> SpeedWeightedObjectList;
// ============================================================================
/** A class to store the headlights of a kart.
*/
class HeadlightObject class HeadlightObject
{ {
private:
/** The filename of the headlight model. */
std::string m_filename; std::string m_filename;
/** The position relative to the parent kart scene node where the
* headlight mesh is attached to. */
core::vector3df m_position; core::vector3df m_position;
/** The mesh for the headlight. */
scene::IMesh* m_model;
/** The scene node of the headlight. */
scene::ISceneNode* m_node;
public: public:
scene::IMesh* m_model;
scene::ISceneNode* m_node;
HeadlightObject() HeadlightObject()
{ {
m_model = NULL; m_model = NULL;
m_node = NULL; m_node = NULL;
} m_filename = "";
m_position.set(0, 0, 0);
HeadlightObject(const std::string& filename, core::vector3df pos) } // HeadlightObject
// ------------------------------------------------------------------------
HeadlightObject(const std::string& filename, core::vector3df &pos)
{ {
m_filename = filename; m_filename = filename;
m_position = pos; m_position = pos;
m_model = NULL; m_model = NULL;
m_node = NULL; m_node = NULL;
} } // HeadlightObjects
// ------------------------------------------------------------------------
const std::string& getFilename() const { return m_filename; } const std::string& getFilename() const { return m_filename; }
const core::vector3df getPosition() const { return m_position; } // ------------------------------------------------------------------------
}; /** Sets the mesh for this headlight object. */
void setModel(scene::IMesh *mesh) { m_model = mesh; }
// ------------------------------------------------------------------------
/** Sets the node of the headlight, and (if not NULL) also sets the
* position of this scene node to be the position of the headlight. */
void setNode(scene::ISceneNode *node)
{
m_node = node;
if (m_node) m_node->setPosition(m_position);
} // setNode
// ------------------------------------------------------------------------
const scene::ISceneNode *getNode() const { return m_node; }
// ------------------------------------------------------------------------
scene::ISceneNode *getNode() { return m_node; }
// ------------------------------------------------------------------------
const scene::IMesh *getModel() const { return m_model; }
// ------------------------------------------------------------------------
scene::IMesh *getModel() { return m_model; }
// ------------------------------------------------------------------------
}; // class HeadlightObject
// ============================================================================
/** /**
* \brief This class stores a 3D kart model. * \brief This class stores a 3D kart model.

View File

@ -87,14 +87,14 @@ void MainMenuScreen::loadedFromFile()
LabelWidget* w = getWidget<LabelWidget>("info_addons"); LabelWidget* w = getWidget<LabelWidget>("info_addons");
w->setScrollSpeed(15); w->setScrollSpeed(15);
IconButtonWidget* iw = getWidget<IconButtonWidget>("story"); RibbonWidget* rw_top = getWidget<RibbonWidget>("menu_toprow");
assert(iw != NULL); assert(rw_top != NULL);
if (track_manager->getTrack("overworld") == NULL || if (track_manager->getTrack("overworld") == NULL ||
track_manager->getTrack("introcutscene") == NULL || track_manager->getTrack("introcutscene") == NULL ||
track_manager->getTrack("introcutscene2") == NULL) track_manager->getTrack("introcutscene2") == NULL)
{ {
iw->setVisible(false); rw_top->removeChildNamed("story");
} }
#if DEBUG_MENU_ITEM != 1 #if DEBUG_MENU_ITEM != 1

View File

@ -123,7 +123,7 @@ RaceGUIOverworld::RaceGUIOverworld()
{ {
m_map_left = (int)((irr_driver->getActualScreenSize().Width - m_map_left = (int)((irr_driver->getActualScreenSize().Width -
m_map_width) * 0.9f); m_map_width) * 0.9f);
m_map_bottom = m_map_height + 10 * scaling; m_map_bottom = m_map_height + int(10 * scaling);
} }
m_speed_meter_icon = material_manager->getMaterial("speedback.png"); m_speed_meter_icon = material_manager->getMaterial("speedback.png");