mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:36:26 +02:00
Merge pull request #13340 from SamGondelman/modelTextures
Try to fix ModelOverlay texture loading
This commit is contained in:
commit
e8ec32c7f8
4 changed files with 13 additions and 15 deletions
|
@ -131,6 +131,9 @@ void ModelOverlay::update(float deltatime) {
|
||||||
|
|
||||||
if (!_texturesLoaded && _model->getGeometry() && _model->getGeometry()->areTexturesLoaded()) {
|
if (!_texturesLoaded && _model->getGeometry() && _model->getGeometry()->areTexturesLoaded()) {
|
||||||
_texturesLoaded = true;
|
_texturesLoaded = true;
|
||||||
|
if (!_modelTextures.isEmpty()) {
|
||||||
|
_model->setTextures(_modelTextures);
|
||||||
|
}
|
||||||
_model->updateRenderItems();
|
_model->updateRenderItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,8 +232,7 @@ void ModelOverlay::setProperties(const QVariantMap& properties) {
|
||||||
if (texturesValue.isValid() && texturesValue.canConvert(QVariant::Map)) {
|
if (texturesValue.isValid() && texturesValue.canConvert(QVariant::Map)) {
|
||||||
_texturesLoaded = false;
|
_texturesLoaded = false;
|
||||||
QVariantMap textureMap = texturesValue.toMap();
|
QVariantMap textureMap = texturesValue.toMap();
|
||||||
QMetaObject::invokeMethod(_model.get(), "setTextures", Qt::AutoConnection,
|
_modelTextures = textureMap;
|
||||||
Q_ARG(const QVariantMap&, textureMap));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto groupCulledValue = properties["isGroupCulled"];
|
auto groupCulledValue = properties["isGroupCulled"];
|
||||||
|
|
|
@ -1074,15 +1074,11 @@ int Model::getLastFreeJointIndex(int jointIndex) const {
|
||||||
|
|
||||||
void Model::setTextures(const QVariantMap& textures) {
|
void Model::setTextures(const QVariantMap& textures) {
|
||||||
if (isLoaded()) {
|
if (isLoaded()) {
|
||||||
_needsUpdateTextures = true;
|
_pendingTextures.clear();
|
||||||
_needsFixupInScene = true;
|
_needsFixupInScene = true;
|
||||||
_renderGeometry->setTextures(textures);
|
_renderGeometry->setTextures(textures);
|
||||||
} else {
|
} else {
|
||||||
// FIXME(Huffman): Disconnect previously connected lambdas so we don't set textures multiple
|
_pendingTextures = textures;
|
||||||
// after the geometry has finished loading.
|
|
||||||
connect(&_renderWatcher, &GeometryResourceWatcher::finished, this, [this, textures]() {
|
|
||||||
_renderGeometry->setTextures(textures);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,7 +1102,8 @@ void Model::setURL(const QUrl& url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_needsReload = true;
|
_needsReload = true;
|
||||||
_needsUpdateTextures = true;
|
// One might be tempted to _pendingTextures.clear(), thinking that a new URL means an old texture doesn't apply.
|
||||||
|
// But sometimes, particularly when first setting the values, the texture might be set first. So let's not clear here.
|
||||||
_visualGeometryRequestFailed = false;
|
_visualGeometryRequestFailed = false;
|
||||||
_needsFixupInScene = true;
|
_needsFixupInScene = true;
|
||||||
invalidCalculatedMeshBoxes();
|
invalidCalculatedMeshBoxes();
|
||||||
|
@ -1123,6 +1120,8 @@ void Model::setURL(const QUrl& url) {
|
||||||
void Model::loadURLFinished(bool success) {
|
void Model::loadURLFinished(bool success) {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
_visualGeometryRequestFailed = true;
|
_visualGeometryRequestFailed = true;
|
||||||
|
} else if (!_pendingTextures.empty()) {
|
||||||
|
setTextures(_pendingTextures);
|
||||||
}
|
}
|
||||||
emit setURLFinished(success);
|
emit setURLFinished(success);
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,7 +457,7 @@ protected:
|
||||||
bool _needsFixupInScene { true }; // needs to be removed/re-added to scene
|
bool _needsFixupInScene { true }; // needs to be removed/re-added to scene
|
||||||
bool _needsReload { true };
|
bool _needsReload { true };
|
||||||
bool _needsUpdateClusterMatrices { true };
|
bool _needsUpdateClusterMatrices { true };
|
||||||
mutable bool _needsUpdateTextures { true };
|
QVariantMap _pendingTextures { };
|
||||||
|
|
||||||
friend class ModelMeshPartPayload;
|
friend class ModelMeshPartPayload;
|
||||||
Rig _rig;
|
Rig _rig;
|
||||||
|
|
|
@ -40,7 +40,6 @@ var HOVER_TEXTURES = {
|
||||||
var UNSELECTED_COLOR = { red: 0x1F, green: 0xC6, blue: 0xA6};
|
var UNSELECTED_COLOR = { red: 0x1F, green: 0xC6, blue: 0xA6};
|
||||||
var SELECTED_COLOR = {red: 0xF3, green: 0x91, blue: 0x29};
|
var SELECTED_COLOR = {red: 0xF3, green: 0x91, blue: 0x29};
|
||||||
var HOVER_COLOR = {red: 0xD0, green: 0xD0, blue: 0xD0}; // almost white for now
|
var HOVER_COLOR = {red: 0xD0, green: 0xD0, blue: 0xD0}; // almost white for now
|
||||||
var conserveResources = true;
|
|
||||||
|
|
||||||
Script.include("/~/system/libraries/controllers.js");
|
Script.include("/~/system/libraries/controllers.js");
|
||||||
|
|
||||||
|
@ -431,7 +430,7 @@ function addAvatarNode(id) {
|
||||||
alpha: 0.8,
|
alpha: 0.8,
|
||||||
color: color(selected, false, 0.0),
|
color: color(selected, false, 0.0),
|
||||||
ignoreRayIntersection: false
|
ignoreRayIntersection: false
|
||||||
}, selected, !conserveResources);
|
}, selected, true);
|
||||||
}
|
}
|
||||||
// Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter.
|
// Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter.
|
||||||
var avatarsOfInterest = {};
|
var avatarsOfInterest = {};
|
||||||
|
@ -496,7 +495,6 @@ function populateNearbyUserList(selectData, oldAudioData) {
|
||||||
print('PAL data:', JSON.stringify(avatarPalDatum));
|
print('PAL data:', JSON.stringify(avatarPalDatum));
|
||||||
});
|
});
|
||||||
getConnectionData(false, location.domainID); // Even admins don't get relationship data in requestUsernameFromID (which is still needed for admin status, which comes from domain).
|
getConnectionData(false, location.domainID); // Even admins don't get relationship data in requestUsernameFromID (which is still needed for admin status, which comes from domain).
|
||||||
conserveResources = Object.keys(avatarsOfInterest).length > 20;
|
|
||||||
sendToQml({ method: 'nearbyUsers', params: data });
|
sendToQml({ method: 'nearbyUsers', params: data });
|
||||||
if (selectData) {
|
if (selectData) {
|
||||||
selectData[2] = true;
|
selectData[2] = true;
|
||||||
|
@ -719,7 +717,7 @@ function onTabletScreenChanged(type, url) {
|
||||||
ContextOverlay.enabled = false;
|
ContextOverlay.enabled = false;
|
||||||
Users.requestsDomainListData = true;
|
Users.requestsDomainListData = true;
|
||||||
|
|
||||||
audioTimer = createAudioInterval(conserveResources ? AUDIO_LEVEL_CONSERVED_UPDATE_INTERVAL_MS : AUDIO_LEVEL_UPDATE_INTERVAL_MS);
|
audioTimer = createAudioInterval(AUDIO_LEVEL_UPDATE_INTERVAL_MS);
|
||||||
|
|
||||||
tablet.tabletShownChanged.connect(tabletVisibilityChanged);
|
tablet.tabletShownChanged.connect(tabletVisibilityChanged);
|
||||||
Script.update.connect(updateOverlays);
|
Script.update.connect(updateOverlays);
|
||||||
|
@ -874,7 +872,6 @@ startup();
|
||||||
var isWired = false;
|
var isWired = false;
|
||||||
var audioTimer;
|
var audioTimer;
|
||||||
var AUDIO_LEVEL_UPDATE_INTERVAL_MS = 100; // 10hz for now (change this and change the AVERAGING_RATIO too)
|
var AUDIO_LEVEL_UPDATE_INTERVAL_MS = 100; // 10hz for now (change this and change the AVERAGING_RATIO too)
|
||||||
var AUDIO_LEVEL_CONSERVED_UPDATE_INTERVAL_MS = 300;
|
|
||||||
function off() {
|
function off() {
|
||||||
if (isWired) {
|
if (isWired) {
|
||||||
Script.update.disconnect(updateOverlays);
|
Script.update.disconnect(updateOverlays);
|
||||||
|
|
Loading…
Reference in a new issue