mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 06:02:28 +02:00
REmoving more repetitions of the meshParts
This commit is contained in:
parent
eaa4d9d596
commit
936ac6f120
3 changed files with 3 additions and 32 deletions
|
@ -295,7 +295,7 @@ void ModelResource::onGeometryMappingLoaded(bool success) {
|
|||
if (success && _modelResource) {
|
||||
_hfmModel = _modelResource->_hfmModel;
|
||||
_materialMapping = _modelResource->_materialMapping;
|
||||
_meshParts = _modelResource->_meshParts;
|
||||
// _meshParts = _modelResource->_meshParts;
|
||||
_meshes = _modelResource->_meshes;
|
||||
_materials = _modelResource->_materials;
|
||||
|
||||
|
@ -329,21 +329,13 @@ void ModelResource::setGeometryDefinition(HFMModel::Pointer hfmModel, const Mate
|
|||
}
|
||||
|
||||
std::shared_ptr<GeometryMeshes> meshes = std::make_shared<GeometryMeshes>();
|
||||
std::shared_ptr<GeometryMeshParts> parts = std::make_shared<GeometryMeshParts>();
|
||||
int meshID = 0;
|
||||
for (const HFMMesh& mesh : _hfmModel->meshes) {
|
||||
// Copy mesh pointers
|
||||
meshes->emplace_back(mesh._mesh);
|
||||
int partID = 0;
|
||||
for (const HFMMeshPart& part : mesh.parts) {
|
||||
// Construct local parts
|
||||
parts->push_back(std::make_shared<MeshPart>(meshID, partID, (int)materialIDAtlas[part.materialID]));
|
||||
partID++;
|
||||
}
|
||||
meshID++;
|
||||
}
|
||||
_meshes = meshes;
|
||||
_meshParts = parts;
|
||||
|
||||
finishedLoading(true);
|
||||
}
|
||||
|
@ -428,7 +420,6 @@ NetworkModel::NetworkModel(const NetworkModel& networkModel) {
|
|||
_hfmModel = networkModel._hfmModel;
|
||||
_materialMapping = networkModel._materialMapping;
|
||||
_meshes = networkModel._meshes;
|
||||
_meshParts = networkModel._meshParts;
|
||||
|
||||
_materials.reserve(networkModel._materials.size());
|
||||
for (const auto& material : networkModel._materials) {
|
||||
|
@ -500,15 +491,8 @@ bool NetworkModel::areTexturesLoaded() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
const std::shared_ptr<NetworkMaterial> NetworkModel::getShapeMaterial(int partID) const {
|
||||
/* if ((partID >= 0) && (partID < (int)_meshParts->size())) {
|
||||
int materialID = _meshParts->at(partID)->materialID;
|
||||
if ((materialID >= 0) && (materialID < (int)_materials.size())) {
|
||||
return _materials[materialID];
|
||||
}
|
||||
}*/
|
||||
|
||||
auto materialID = getHFMModel().shapes[partID].material;
|
||||
const std::shared_ptr<NetworkMaterial> NetworkModel::getShapeMaterial(int shapeID) const {
|
||||
auto materialID = getHFMModel().shapes[shapeID].material;
|
||||
if ((materialID >= 0) && (materialID < (int)_materials.size())) {
|
||||
return _materials[materialID];
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include <material-networking/TextureCache.h>
|
||||
#include "ModelLoader.h"
|
||||
|
||||
class MeshPart;
|
||||
|
||||
using GeometryMappingPair = std::pair<QUrl, QVariantHash>;
|
||||
Q_DECLARE_METATYPE(GeometryMappingPair)
|
||||
|
||||
|
@ -38,7 +36,6 @@ public:
|
|||
|
||||
// Immutable over lifetime
|
||||
using GeometryMeshes = std::vector<std::shared_ptr<const graphics::Mesh>>;
|
||||
using GeometryMeshParts = std::vector<std::shared_ptr<const MeshPart>>;
|
||||
|
||||
// Mutable, but must retain structure of vector
|
||||
using NetworkMaterials = std::vector<std::shared_ptr<NetworkMaterial>>;
|
||||
|
@ -63,7 +60,6 @@ protected:
|
|||
HFMModel::ConstPointer _hfmModel;
|
||||
MaterialMapping _materialMapping;
|
||||
std::shared_ptr<const GeometryMeshes> _meshes;
|
||||
std::shared_ptr<const GeometryMeshParts> _meshParts;
|
||||
|
||||
// Copied to each geometry, mutable throughout lifetime via setTextures
|
||||
NetworkMaterials _materials;
|
||||
|
@ -180,12 +176,4 @@ private:
|
|||
ModelLoader _modelLoader;
|
||||
};
|
||||
|
||||
class MeshPart {
|
||||
public:
|
||||
MeshPart(int mesh, int part, int material) : meshID { mesh }, partID { part }, materialID { material } {}
|
||||
int meshID { -1 };
|
||||
int partID { -1 };
|
||||
int materialID { -1 };
|
||||
};
|
||||
|
||||
#endif // hifi_ModelCache_h
|
||||
|
|
|
@ -1687,7 +1687,6 @@ public:
|
|||
std::shared_ptr<GeometryMeshes> meshes = std::make_shared<GeometryMeshes>();
|
||||
meshes->push_back(mesh);
|
||||
_meshes = meshes;
|
||||
_meshParts = std::shared_ptr<const GeometryMeshParts>();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue