mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into avatar_simulate_optimisation
This commit is contained in:
commit
897481d557
8 changed files with 52 additions and 19 deletions
|
@ -255,13 +255,24 @@ function update(deltaTime){
|
|||
}
|
||||
frame++;
|
||||
}
|
||||
|
||||
var locationChanged = false;
|
||||
if (location.hostname != oldHost) {
|
||||
print("Changed domain");
|
||||
for (model in models) {
|
||||
removeIndicators(models[model]);
|
||||
}
|
||||
oldHost = location.hostname;
|
||||
locationChanged = true;
|
||||
}
|
||||
|
||||
if (MyAvatar.position.x != avatarOldPosition.x &&
|
||||
MyAvatar.position.y != avatarOldPosition.y &&
|
||||
MyAvatar.position.z != avatarOldPosition.z) {
|
||||
if (MyAvatar.position.x != avatarOldPosition.x ||
|
||||
MyAvatar.position.y != avatarOldPosition.y ||
|
||||
MyAvatar.position.z != avatarOldPosition.z ||
|
||||
locationChanged) {
|
||||
avatarOldPosition = MyAvatar.position;
|
||||
|
||||
var SEARCH_RADIUS = 10;
|
||||
var SEARCH_RADIUS = 50;
|
||||
var foundModels = Models.findModels(MyAvatar.position, SEARCH_RADIUS);
|
||||
// Let's remove indicator that got out of radius
|
||||
for (model in models) {
|
||||
|
@ -274,7 +285,10 @@ function update(deltaTime){
|
|||
for (var i = 0; i < foundModels.length; ++i) {
|
||||
var model = foundModels[i];
|
||||
if (typeof(models[model.id]) == "undefined") {
|
||||
addIndicators(model);
|
||||
model.properties = Models.getModelProperties(model);
|
||||
if (Vec3.distance(model.properties.position, MyAvatar.position) < SEARCH_RADIUS) {
|
||||
addIndicators(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,9 +297,9 @@ function update(deltaTime){
|
|||
}
|
||||
}
|
||||
}
|
||||
var oldHost = location.hostname;
|
||||
|
||||
function addIndicators(modelID) {
|
||||
modelID.properties = Models.getModelProperties(modelID);
|
||||
if (modelID.properties.sittingPoints.length > 0) {
|
||||
for (var i = 0; i < modelID.properties.sittingPoints.length; ++i) {
|
||||
modelID.properties.sittingPoints[i].indicator = new SeatIndicator(modelID.properties, i);
|
||||
|
|
|
@ -17,10 +17,11 @@ BillboardOverlay::BillboardOverlay()
|
|||
: _fromImage(-1,-1,-1,-1),
|
||||
_scale(1.0f),
|
||||
_isFacingAvatar(true) {
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
void BillboardOverlay::render() {
|
||||
if (!_visible) {
|
||||
if (!_visible || !_isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,16 +86,7 @@ void BillboardOverlay::render() {
|
|||
((float)_fromImage.y() + (float)_fromImage.height()) / (float)_size.height());
|
||||
glVertex2f(-x, y);
|
||||
} glEnd();
|
||||
} else {
|
||||
glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
glBegin(GL_QUADS); {
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
} glEnd();
|
||||
}
|
||||
|
||||
} glPopMatrix();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -167,6 +159,7 @@ void BillboardOverlay::setProperties(const QScriptValue &properties) {
|
|||
}
|
||||
|
||||
void BillboardOverlay::setBillboardURL(const QUrl url) {
|
||||
_isLoaded = false;
|
||||
QNetworkReply* reply = NetworkAccessManager::getInstance().get(QNetworkRequest(url));
|
||||
connect(reply, &QNetworkReply::finished, this, &BillboardOverlay::replyFinished);
|
||||
}
|
||||
|
@ -175,4 +168,5 @@ void BillboardOverlay::replyFinished() {
|
|||
// replace our byte array with the downloaded data
|
||||
QNetworkReply* reply = static_cast<QNetworkReply*>(sender());
|
||||
_billboard = reply->readAll();
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ ImageOverlay::ImageOverlay() :
|
|||
_textureBound(false),
|
||||
_wantClipFromImage(false)
|
||||
{
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
ImageOverlay::~ImageOverlay() {
|
||||
|
@ -35,6 +36,7 @@ ImageOverlay::~ImageOverlay() {
|
|||
|
||||
// TODO: handle setting image multiple times, how do we manage releasing the bound texture?
|
||||
void ImageOverlay::setImageURL(const QUrl& url) {
|
||||
_isLoaded = false;
|
||||
NetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||
connect(reply, &QNetworkReply::finished, this, &ImageOverlay::replyFinished);
|
||||
|
@ -47,10 +49,11 @@ void ImageOverlay::replyFinished() {
|
|||
QByteArray rawData = reply->readAll();
|
||||
_textureImage.loadFromData(rawData);
|
||||
_renderImage = true;
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
||||
void ImageOverlay::render() {
|
||||
if (!_visible) {
|
||||
if (!_visible || !_isLoaded) {
|
||||
return; // do nothing if we're not visible
|
||||
}
|
||||
if (_renderImage && !_textureBound) {
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
ModelOverlay::ModelOverlay()
|
||||
: _model(),
|
||||
_scale(1.0f),
|
||||
_updateModel(false) {
|
||||
_updateModel(false)
|
||||
{
|
||||
_model.init();
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
void ModelOverlay::update(float deltatime) {
|
||||
|
@ -32,6 +34,7 @@ void ModelOverlay::update(float deltatime) {
|
|||
} else {
|
||||
_model.simulate(deltatime);
|
||||
}
|
||||
_isLoaded = _model.isActive();
|
||||
}
|
||||
|
||||
void ModelOverlay::render() {
|
||||
|
@ -90,6 +93,7 @@ void ModelOverlay::setProperties(const QScriptValue &properties) {
|
|||
if (urlValue.isValid()) {
|
||||
_url = urlValue.toVariant().toString();
|
||||
_updateModel = true;
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
QScriptValue scaleValue = properties.property("scale");
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
Overlay::Overlay() :
|
||||
_parent(NULL),
|
||||
_isLoaded(true),
|
||||
_alpha(DEFAULT_ALPHA),
|
||||
_color(DEFAULT_OVERLAY_COLOR),
|
||||
_visible(true),
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
virtual void render() = 0;
|
||||
|
||||
// getters
|
||||
bool isLoaded() { return _isLoaded; }
|
||||
bool getVisible() const { return _visible; }
|
||||
const xColor& getColor() const { return _color; }
|
||||
float getAlpha() const { return _alpha; }
|
||||
|
@ -55,6 +56,7 @@ public:
|
|||
|
||||
protected:
|
||||
QGLWidget* _parent;
|
||||
bool _isLoaded;
|
||||
float _alpha;
|
||||
xColor _color;
|
||||
bool _visible; // should the overlay be drawn at all
|
||||
|
|
|
@ -227,11 +227,23 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
|||
i.previous();
|
||||
unsigned int thisID = i.key();
|
||||
Overlay2D* thisOverlay = static_cast<Overlay2D*>(i.value());
|
||||
if (thisOverlay->getVisible() && thisOverlay->getBounds().contains(point.x, point.y, false)) {
|
||||
if (thisOverlay->getVisible() && thisOverlay->isLoaded() && thisOverlay->getBounds().contains(point.x, point.y, false)) {
|
||||
return thisID;
|
||||
}
|
||||
}
|
||||
return 0; // not found
|
||||
}
|
||||
|
||||
bool Overlays::isLoaded(unsigned int id) {
|
||||
QReadLocker lock(&_lock);
|
||||
Overlay* overlay = _overlays2D.value(id);
|
||||
if (!overlay) {
|
||||
_overlays3D.value(id);
|
||||
}
|
||||
if (!overlay) {
|
||||
return false; // not found
|
||||
}
|
||||
|
||||
return overlay->isLoaded();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ public slots:
|
|||
|
||||
/// returns the top most overlay at the screen point, or 0 if not overlay at that point
|
||||
unsigned int getOverlayAtPoint(const glm::vec2& point);
|
||||
|
||||
/// returns whether the overlay's assets are loaded or not
|
||||
bool isLoaded(unsigned int id);
|
||||
|
||||
private:
|
||||
QMap<unsigned int, Overlay*> _overlays2D;
|
||||
|
|
Loading…
Reference in a new issue