Skip to content

Commit

Permalink
Merge pull request #893 from overte-org/fix/agent_textures
Browse files Browse the repository at this point in the history
Fix previous commit for not loading textures on agent
  • Loading branch information
ksuprynowicz authored Mar 26, 2024
2 parents d44ae7a + edb3580 commit 36b6010
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 0 additions & 2 deletions assignment-client/src/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ Agent::Agent(ReceivedMessage& message) :

DependencyManager::set<ModelFormatRegistry>();
DependencyManager::set<ModelCache>();
DependencyManager::set<TextureCache>();

// Needed to ensure the creation of the DebugDraw instance on the main thread
DebugDraw::getInstance();
Expand Down Expand Up @@ -849,7 +848,6 @@ void Agent::aboutToFinish() {

DependencyManager::destroy<ModelFormatRegistry>();
DependencyManager::destroy<ModelCache>();
DependencyManager::destroy<TextureCache>();

DependencyManager::destroy<PluginManager>();

Expand Down
3 changes: 0 additions & 3 deletions assignment-client/src/avatars/ScriptableAvatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ static AnimPose composeAnimPose(const HFMJoint& joint, const glm::quat rotation,
}

void ScriptableAvatar::update(float deltatime) {
// TODO: the current decision to use geometry resource results in loading textures, but it works way better
// than previous choice of loading avatar as animation, which was missing data such as joint names hash,
// and also didn't support glTF models. Optimizing this will be left fot future PR.
if (!_geometryResource && !_skeletonModelFilenameURL.isEmpty()) { // AvatarData will parse the .fst, but not get the .fbx skeleton.
_geometryResource = DependencyManager::get<ModelCache>()->getGeometryResource(_skeletonModelFilenameURL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,12 @@ void GeometryResource::deleter() {

void GeometryResource::setTextures() {
if (_hfmModel) {
for (const HFMMaterial& material : _hfmModel->materials) {
_materials.push_back(std::make_shared<NetworkMaterial>(material, _textureBaseURL));
if (DependencyManager::get<TextureCache>()) {
for (const HFMMaterial& material : _hfmModel->materials) {
_materials.push_back(std::make_shared<NetworkMaterial>(material, _textureBaseURL));
}
} else {
qDebug() << "GeometryResource::setTextures: TextureCache dependency not available, skipping textures";
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,13 @@ graphics::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& baseUrl
}

const auto url = getTextureUrl(baseUrl, hfmTexture);
const auto texture = DependencyManager::get<TextureCache>()->getTexture(url, type, hfmTexture.content, hfmTexture.maxNumPixels, hfmTexture.sourceChannel);
auto textureCache = DependencyManager::get<TextureCache>();
NetworkTexturePointer texture;
if (textureCache) {
texture = textureCache->getTexture(url, type, hfmTexture.content, hfmTexture.maxNumPixels, hfmTexture.sourceChannel);
} else {
qDebug() << "GeometryResource::setTextures: TextureCache dependency not available, skipping textures";
}
_textures[channel] = Texture { hfmTexture.name, texture };

auto map = std::make_shared<graphics::TextureMap>();
Expand Down

0 comments on commit 36b6010

Please sign in to comment.