Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit 9b67511a authored by MURRAY David's avatar MURRAY David
Browse files

ok with multiple meshes with multi_mat, need to update doc

parent cb258757
......@@ -1372,17 +1372,14 @@ void OptixMaterialHandler::applyMaterial(/*OptiXMesh &optix_mesh,*/
if (multi_mat)
{
mrf_indices = multi_mat->getAllMRFId();
mesh_indices = multi_mat->getAllMeshId();
}
else
{
mrf_indices.push_back(material_index);
mesh_indices.push_back(0);
}
assert(mesh_indices.size() == mrf_indices.size());
for (unsigned int i = 0; i < mesh_indices.size(); ++i)
for (unsigned int i = 0; i < mrf_indices.size(); ++i)
{
material = _mrf_materials[mrf_indices[i]];
geom_instance->setMaterial(i, _materials.at(material));
......
......@@ -1206,16 +1206,16 @@ SceneParser::addMesh(XMLElement *a_mesh_element, mrf::rendering::Scene &scene, i
//Need to check consistency between indices and remap if necessary.
std::vector<unsigned int> remapping;
//remapping.resize(materials.size());
for (int i = 0; i < materials.size(); ++i)
{
uint index = 0;
while (multi_mat->getAllNames()[index] != materials[i].name() && index < materials.size())
while (multi_mat->getAllNames()[index] != materials[i].name() && index < multi_mat->getAllNames().size()-1)
{
++index;
}
remapping.push_back(multi_mat->getAllMRFId()[index]);
if (index < multi_mat->getAllNames().size())
remapping.push_back(index);
}
enforced_materials.resize(per_face_material.size());
......@@ -1227,7 +1227,9 @@ SceneParser::addMesh(XMLElement *a_mesh_element, mrf::rendering::Scene &scene, i
enforced_materials[i] = remapping[prev];
}
_loger->info("Remapped per face material for OBJ " + obj_relative_path);
_loger->info("Remapped per face material for OBJ " + obj_relative_path + " with:");
for (int i = 0; i < remapping.size(); ++i)
_loger->info("i = " + std::to_string(i) + " | i2 = " + std::to_string(remapping[i]));
assert(enforced_materials.size() == per_face_material.size());
}
......@@ -1563,7 +1565,7 @@ bool SceneParser::addMaterial(XMLElement *a_mat_element, mrf::rendering::Scene &
if (_brdf_map.count(name) == 1)
{
_loger->info("Material " + name + " is already in the list.");
//return false;
return true;
}
std::string type;
......@@ -1587,8 +1589,14 @@ bool SceneParser::addMaterial(XMLElement *a_mat_element, mrf::rendering::Scene &
unsigned int count;
int rOk = a_mat_element->QueryUnsignedAttribute(SceneLexer::COUNT_AT, &count);
MultiMaterial *multimat = new MultiMaterial(name, count);
parseMultiMaterial(a_mat_element, multimat, scene);
_brdf_map[name] = scene.addMaterial(multimat);
bool rOK = parseMultiMaterial(a_mat_element, multimat, scene);
if (rOK)
_brdf_map[name] = scene.addMaterial(multimat);
else
{
_loger->warn("Something went wrong with a mutli-material. Please check that its material are in the scene graph.");
delete multimat;
}
}
else if (type.compare(BRDFTypes::LAMBERT) == 0)
{
......@@ -2769,7 +2777,7 @@ void SceneParser::parsePrincipled(tinyxml2::XMLElement *a_mat_element, mrf::mate
void SceneParser::parseMultiMaterial(
bool SceneParser::parseMultiMaterial(
tinyxml2::XMLElement * a_mat_element,
mrf::materials::MultiMaterial *multi_mat,
mrf::rendering::Scene & scene)
......@@ -2778,6 +2786,7 @@ void SceneParser::parseMultiMaterial(
_loger->trace("Materials Found ! Parsing it....");
bool rOK = true;
for (; material; material = material->NextSiblingElement())
{
std::string element_name = material->Name();
......@@ -2786,25 +2795,15 @@ void SceneParser::parseMultiMaterial(
{
std::string name(material->Attribute(SceneLexer::NAME_AT));
unsigned int mat_index;
material->QueryUnsignedAttribute(SceneLexer::INDEX_AT, &mat_index);
if (_brdf_map.count(name) != 1)
addMaterial(material, scene);
multi_mat->addEntry(_brdf_map[name], mat_index, name);
}
//TODO
//else if (element_name.compare(SceneLexer::EMITTANCE_MK) == 0)
//{
// if (!addEmittance(material, scene))
// {
// _loger->warn("Problem while trying to add an emittance in parse materials");
// }
//}
//else
//{
// _loger->warn("Unrecognized element in materials ");
//}
rOK &= addMaterial(material, scene);
multi_mat->addEntry(_brdf_map[name], name);
}
}
return rOK;
}
bool SceneParser::parseTexture(XMLElement *a_mat_element, char const *texture_markup, std::string &path)
{
XMLElement *texture_elem = a_mat_element->FirstChildElement(texture_markup);
......
......@@ -122,7 +122,7 @@ protected:
void parsePrincipled(tinyxml2::XMLElement *a_mat_element, mrf::materials::PrincipledDisney *principled_mat);
void parseMultiMaterial(
bool parseMultiMaterial(
tinyxml2::XMLElement * a_mat_element,
mrf::materials::MultiMaterial *multi_mat,
mrf::rendering::Scene & scene);
......
......@@ -16,14 +16,8 @@ namespace materials
class MRF_CORE_EXPORT MultiMaterial: public BRDF
{
protected:
std::map<unsigned int, std::string> _material_map;
//std::map<unsigned int, UMat *> _material_map;
unsigned int _index_offset;
unsigned int _material_count;
std::vector<unsigned int> _mrf_indices;
std::vector<unsigned int> _mesh_indices;
std::vector<std::string> _names;
public:
......@@ -31,18 +25,15 @@ public:
~MultiMaterial();
//void addEntry(unsigned int idx, std::string name) { _material_map[idx] = name; }
void addEntry(unsigned int mrf_idx, unsigned int mesh_idx, std::string name)
void addEntry(unsigned int mrf_idx, std::string name)
{
_mrf_indices.push_back(mrf_idx);
_mesh_indices.push_back(mesh_idx);
_names.push_back(name);
}
void addMRFIdEntry(unsigned int idx) { _mrf_indices.push_back(idx); }
void addMeshIdEntry(unsigned int idx) { _mesh_indices.push_back(idx); }
void addNameEntry(std::string name) { _names.push_back(name); }
std::vector<unsigned int> &getAllMRFId() { return _mrf_indices; }
std::vector<unsigned int> &getAllMeshId() { return _mesh_indices; }
std::vector<std::string> & getAllNames() { return _names; }
};
} // namespace materials
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment