mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:24:24 +02:00
quick optimization to RenderableModelEntityItem::render()
This commit is contained in:
parent
e9f2cadfff
commit
f4c3c30f6a
3 changed files with 20 additions and 13 deletions
|
@ -227,24 +227,30 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
||||||
|
|
||||||
if (hasModel()) {
|
if (hasModel()) {
|
||||||
if (_model) {
|
if (_model) {
|
||||||
if (QUrl(getModelURL()) != _model->getURL()) {
|
if (getModelURL() != _model->getURLAsString()) {
|
||||||
qDebug() << "Updating model URL: " << getModelURL();
|
qDebug() << "Updating model URL: " << getModelURL();
|
||||||
_model->setURL(getModelURL());
|
_model->setURL(getModelURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||||
|
|
||||||
// check to see if when we added our models to the scene they were ready, if they were not ready, then
|
// check to see if when we added our models to the scene they were ready, if they were not ready, then
|
||||||
// fix them up in the scene
|
// fix them up in the scene
|
||||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
|
||||||
render::PendingChanges pendingChanges;
|
|
||||||
if (_model->needsFixupInScene()) {
|
if (_model->needsFixupInScene()) {
|
||||||
|
render::PendingChanges pendingChanges;
|
||||||
|
|
||||||
_model->removeFromScene(scene, pendingChanges);
|
_model->removeFromScene(scene, pendingChanges);
|
||||||
|
|
||||||
render::Item::Status::Getters statusGetters;
|
render::Item::Status::Getters statusGetters;
|
||||||
makeEntityItemStatusGetters(this, statusGetters);
|
makeEntityItemStatusGetters(this, statusGetters);
|
||||||
_model->addToScene(scene, pendingChanges, statusGetters);
|
_model->addToScene(scene, pendingChanges, statusGetters);
|
||||||
}
|
|
||||||
scene->enqueuePendingChanges(pendingChanges);
|
|
||||||
|
|
||||||
|
scene->enqueuePendingChanges(pendingChanges);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: this seems like it could be optimized if we tracked our last known visible state in
|
||||||
|
// the renderable item. As it stands now the model checks it's visible/invisible state
|
||||||
|
// so most of the time we don't do anything in this function.
|
||||||
_model->setVisibleInScene(getVisible(), scene);
|
_model->setVisibleInScene(getVisible(), scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ static int modelPointerTypeId = qRegisterMetaType<QPointer<Model> >();
|
||||||
static int weakNetworkGeometryPointerTypeId = qRegisterMetaType<QWeakPointer<NetworkGeometry> >();
|
static int weakNetworkGeometryPointerTypeId = qRegisterMetaType<QWeakPointer<NetworkGeometry> >();
|
||||||
static int vec3VectorTypeId = qRegisterMetaType<QVector<glm::vec3> >();
|
static int vec3VectorTypeId = qRegisterMetaType<QVector<glm::vec3> >();
|
||||||
float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
|
float Model::FAKE_DIMENSION_PLACEHOLDER = -1.0f;
|
||||||
|
#define HTTP_INVALID_COM "http://invalid.com"
|
||||||
|
|
||||||
Model::Model(RigPointer rig, QObject* parent) :
|
Model::Model(RigPointer rig, QObject* parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
@ -67,7 +68,8 @@ Model::Model(RigPointer rig, QObject* parent) :
|
||||||
_cauterizeBones(false),
|
_cauterizeBones(false),
|
||||||
_lodDistance(0.0f),
|
_lodDistance(0.0f),
|
||||||
_pupilDilation(0.0f),
|
_pupilDilation(0.0f),
|
||||||
_url("http://invalid.com"),
|
_url(HTTP_INVALID_COM),
|
||||||
|
_urlAsString(HTTP_INVALID_COM),
|
||||||
_isVisible(true),
|
_isVisible(true),
|
||||||
_blendNumber(0),
|
_blendNumber(0),
|
||||||
_appliedBlendNumber(0),
|
_appliedBlendNumber(0),
|
||||||
|
@ -181,17 +183,12 @@ void Model::RenderPipelineLib::initLocations(gpu::ShaderPointer& program, Model:
|
||||||
locations.texcoordMatrices = program->getUniforms().findLocation("texcoordMatrices");
|
locations.texcoordMatrices = program->getUniforms().findLocation("texcoordMatrices");
|
||||||
locations.emissiveParams = program->getUniforms().findLocation("emissiveParams");
|
locations.emissiveParams = program->getUniforms().findLocation("emissiveParams");
|
||||||
locations.glowIntensity = program->getUniforms().findLocation("glowIntensity");
|
locations.glowIntensity = program->getUniforms().findLocation("glowIntensity");
|
||||||
|
|
||||||
locations.normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap");
|
locations.normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap");
|
||||||
|
|
||||||
locations.specularTextureUnit = program->getTextures().findLocation("specularMap");
|
locations.specularTextureUnit = program->getTextures().findLocation("specularMap");
|
||||||
locations.emissiveTextureUnit = program->getTextures().findLocation("emissiveMap");
|
locations.emissiveTextureUnit = program->getTextures().findLocation("emissiveMap");
|
||||||
|
|
||||||
locations.materialBufferUnit = program->getBuffers().findLocation("materialBuffer");
|
locations.materialBufferUnit = program->getBuffers().findLocation("materialBuffer");
|
||||||
locations.lightBufferUnit = program->getBuffers().findLocation("lightBuffer");
|
locations.lightBufferUnit = program->getBuffers().findLocation("lightBuffer");
|
||||||
|
|
||||||
locations.clusterMatrices = program->getUniforms().findLocation("clusterMatrices");
|
locations.clusterMatrices = program->getUniforms().findLocation("clusterMatrices");
|
||||||
|
|
||||||
locations.clusterIndices = program->getInputs().findLocation("inSkinClusterIndex");
|
locations.clusterIndices = program->getInputs().findLocation("inSkinClusterIndex");
|
||||||
locations.clusterWeights = program->getInputs().findLocation("inSkinClusterWeight");
|
locations.clusterWeights = program->getInputs().findLocation("inSkinClusterWeight");
|
||||||
}
|
}
|
||||||
|
@ -1085,6 +1082,7 @@ void Model::setURL(const QUrl& url, const QUrl& fallback, bool retainCurrent, bo
|
||||||
invalidCalculatedMeshBoxes();
|
invalidCalculatedMeshBoxes();
|
||||||
|
|
||||||
_url = url;
|
_url = url;
|
||||||
|
_urlAsString = _url.toString();
|
||||||
|
|
||||||
onInvalidate();
|
onInvalidate();
|
||||||
|
|
||||||
|
@ -1868,8 +1866,9 @@ void Model::pickPrograms(gpu::Batch& batch, RenderMode mode, bool translucent, f
|
||||||
batch._glUniform1f(locations->glowIntensity, DEFAULT_GLOW_INTENSITY);
|
batch._glUniform1f(locations->glowIntensity, DEFAULT_GLOW_INTENSITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((locations->normalFittingMapUnit > -1)) {
|
if ((locations->normalFittingMapUnit > -1)) {
|
||||||
batch.setResourceTexture(locations->normalFittingMapUnit, DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
batch.setResourceTexture(locations->normalFittingMapUnit,
|
||||||
|
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
Q_INVOKABLE void setURL(const QUrl& url, const QUrl& fallback = QUrl(),
|
Q_INVOKABLE void setURL(const QUrl& url, const QUrl& fallback = QUrl(),
|
||||||
bool retainCurrent = false, bool delayLoad = false);
|
bool retainCurrent = false, bool delayLoad = false);
|
||||||
const QUrl& getURL() const { return _url; }
|
const QUrl& getURL() const { return _url; }
|
||||||
|
const QString& getURLAsString() const { return _urlAsString; }
|
||||||
|
|
||||||
// new Scene/Engine rendering support
|
// new Scene/Engine rendering support
|
||||||
void setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scene);
|
void setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scene);
|
||||||
|
@ -328,6 +329,7 @@ private:
|
||||||
QVector<float> _blendshapeCoefficients;
|
QVector<float> _blendshapeCoefficients;
|
||||||
|
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
|
QString _urlAsString;
|
||||||
QUrl _collisionUrl;
|
QUrl _collisionUrl;
|
||||||
bool _isVisible;
|
bool _isVisible;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue