mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-08-20 01:13:08 +02:00
Rename a few more confusing names.
setTransforms -> applyTransformTo attachedPanel -> parentPanel
This commit is contained in:
parent
b94be926f8
commit
497713b020
12 changed files with 65 additions and 64 deletions
|
@ -170,7 +170,7 @@ function onMouseUp(event) {
|
|||
if (event.isLeftButton) {
|
||||
var overlay = OverlayManager.findAtPoint({ x: event.x, y: event.y });
|
||||
if (overlay && overlay === mouseDown.overlay) {
|
||||
if (overlay.attachedPanel === bluePanel) {
|
||||
if (overlay.parentPanel === bluePanel) {
|
||||
overlay.destroy();
|
||||
} else {
|
||||
overlay.offsetPosition = Vec3.sum(overlay.offsetPosition, { x: 0, y: 0, z: -0.1 });
|
||||
|
|
|
@ -254,9 +254,9 @@
|
|||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(that.prototype, "attachedPanel", {
|
||||
Object.defineProperty(that.prototype, "parentPanel", {
|
||||
get: function() {
|
||||
return findPanel(Overlays.getAttachedPanel(this._id));
|
||||
return findPanel(Overlays.getParentPanel(this._id));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -399,9 +399,9 @@
|
|||
});
|
||||
});
|
||||
|
||||
Object.defineProperty(that.prototype, "attachedPanel", {
|
||||
Object.defineProperty(that.prototype, "parentPanel", {
|
||||
get: function() {
|
||||
return findPanel(Overlays.getAttachedPanel(this._id));
|
||||
return findPanel(Overlays.getParentPanel(this._id));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -417,13 +417,13 @@
|
|||
});
|
||||
|
||||
that.prototype.addChild = function(child) {
|
||||
Overlays.setAttachedPanel(child._id, this._id);
|
||||
Overlays.setParentPanel(child._id, this._id);
|
||||
return child;
|
||||
};
|
||||
|
||||
that.prototype.removeChild = function(child) {
|
||||
if (child.attachedPanel === this) {
|
||||
Overlays.setAttachedPanel(child._id, 0);
|
||||
if (child.parentPanel === this) {
|
||||
Overlays.setParentPanel(child._id, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -450,8 +450,8 @@
|
|||
|
||||
function onOverlayDeleted(id) {
|
||||
if (id in overlays) {
|
||||
if (overlays[id].attachedPanel) {
|
||||
overlays[id].attachedPanel.removeChild(overlays[id]);
|
||||
if (overlays[id].parentPanel) {
|
||||
overlays[id].parentPanel.removeChild(overlays[id]);
|
||||
}
|
||||
delete overlays[id];
|
||||
}
|
||||
|
@ -459,8 +459,8 @@
|
|||
|
||||
function onPanelDeleted(id) {
|
||||
if (id in panels) {
|
||||
if (panels[id].attachedPanel) {
|
||||
panels[id].attachedPanel.removeChild(panels[id]);
|
||||
if (panels[id].parentPanel) {
|
||||
panels[id].parentPanel.removeChild(panels[id]);
|
||||
}
|
||||
delete panels[id];
|
||||
}
|
||||
|
|
|
@ -46,10 +46,11 @@ QScriptValue Billboard3DOverlay::getProperty(const QString &property) {
|
|||
return Planar3DOverlay::getProperty(property);
|
||||
}
|
||||
|
||||
void Billboard3DOverlay::setTransforms(Transform& transform) {
|
||||
PanelAttachable::setTransforms(transform);
|
||||
void Billboard3DOverlay::applyTransformTo(Transform& transform) {
|
||||
PanelAttachable::applyTransformTo(transform);
|
||||
if (_isFacingAvatar) {
|
||||
glm::quat rotation = Application::getInstance()->getCamera()->getOrientation();
|
||||
|
||||
transform.setRotation(rotation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
virtual QScriptValue getProperty(const QString& property);
|
||||
|
||||
protected:
|
||||
virtual void setTransforms(Transform& transform);
|
||||
virtual void applyTransformTo(Transform& transform);
|
||||
|
||||
private:
|
||||
bool _isFacingAvatar;
|
||||
|
|
|
@ -38,7 +38,7 @@ Image3DOverlay::Image3DOverlay(const Image3DOverlay* image3DOverlay) :
|
|||
}
|
||||
|
||||
void Image3DOverlay::update(float deltatime) {
|
||||
setTransforms(_transform);
|
||||
applyTransformTo(_transform);
|
||||
}
|
||||
|
||||
void Image3DOverlay::render(RenderArgs* args) {
|
||||
|
@ -87,7 +87,7 @@ void Image3DOverlay::render(RenderArgs* args) {
|
|||
xColor color = getColor();
|
||||
float alpha = getAlpha();
|
||||
|
||||
setTransforms(_transform);
|
||||
applyTransformTo(_transform);
|
||||
Transform transform = _transform;
|
||||
transform.postScale(glm::vec3(getDimensions(), 1.0f));
|
||||
transform.postRotate(glm::angleAxis(glm::pi<float>(), IDENTITY_UP));
|
||||
|
@ -170,7 +170,7 @@ bool Image3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec
|
|||
float& distance, BoxFace& face) {
|
||||
if (_texture && _texture->isLoaded()) {
|
||||
// Make sure position and rotation is updated.
|
||||
setTransforms(_transform);
|
||||
applyTransformTo(_transform);
|
||||
|
||||
// Produce the dimensions of the overlay based on the image's aspect ratio and the overlay's scale.
|
||||
bool isNull = _fromImage.isNull();
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
#include "Base3DOverlay.h"
|
||||
|
||||
glm::vec3 OverlayPanel::getComputedPosition() const {
|
||||
if (getAttachedPanel()) {
|
||||
return getAttachedPanel()->getComputedRotation() * getAttachedPanel()->getOffsetPosition() +
|
||||
getAttachedPanel()->getComputedPosition();
|
||||
if (getParentPanel()) {
|
||||
return getParentPanel()->getComputedRotation() * getParentPanel()->getOffsetPosition() +
|
||||
getParentPanel()->getComputedPosition();
|
||||
} else if (_positionBindMyAvatar) {
|
||||
return DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition();
|
||||
} else if (!_positionBindEntity.isNull()) {
|
||||
|
@ -35,8 +35,8 @@ glm::vec3 OverlayPanel::getComputedPosition() const {
|
|||
}
|
||||
|
||||
glm::quat OverlayPanel::getComputedRotation() const {
|
||||
if (getAttachedPanel()) {
|
||||
return getAttachedPanel()->getComputedRotation() * getAttachedPanel()->getFacingRotation();
|
||||
if (getParentPanel()) {
|
||||
return getParentPanel()->getComputedRotation() * getParentPanel()->getFacingRotation();
|
||||
} else if (_rotationBindMyAvatar) {
|
||||
return DependencyManager::get<AvatarManager>()->getMyAvatar()->getOrientation() *
|
||||
glm::angleAxis(glm::pi<float>(), IDENTITY_UP);
|
||||
|
@ -48,8 +48,8 @@ glm::quat OverlayPanel::getComputedRotation() const {
|
|||
}
|
||||
|
||||
bool OverlayPanel::getParentVisible() const {
|
||||
if (getAttachedPanel()) {
|
||||
return getAttachedPanel()->getVisible() && getAttachedPanel()->getParentVisible();
|
||||
if (getParentPanel()) {
|
||||
return getParentPanel()->getVisible() && getParentPanel()->getParentVisible();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
glm::quat getComputedRotation() const;
|
||||
glm::vec3 getOffsetPosition() const { return _offsetPosition; }
|
||||
glm::quat getFacingRotation() const { return _offsetRotation; }
|
||||
Pointer getAttachedPanel() const { return _attachedPanel; }
|
||||
Pointer getParentPanel() const { return _parentPanel; }
|
||||
bool getVisible() const { return _visible; }
|
||||
bool getParentVisible() const;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
|||
void setRotation(const glm::quat& rotation) { _rotation = rotation; }
|
||||
void setOffsetPosition(const glm::vec3& position) { _offsetPosition = position; }
|
||||
void setFacingRotation(const glm::quat& rotation) { _offsetRotation = rotation; }
|
||||
void setAttachedPanel(Pointer panel) { _attachedPanel = panel; }
|
||||
void setParentPanel(Pointer panel) { _parentPanel = panel; }
|
||||
void setVisible(bool visible) { _visible = visible; }
|
||||
|
||||
const QList<unsigned int>& getChildren() { return _children; }
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
bool _rotationBindMyAvatar = false;
|
||||
QUuid _rotationBindEntity;
|
||||
|
||||
Pointer _attachedPanel = nullptr;
|
||||
Pointer _parentPanel = nullptr;
|
||||
QList<unsigned int> _children;
|
||||
bool _visible = true;
|
||||
|
||||
|
|
|
@ -204,8 +204,8 @@ unsigned int Overlays::cloneOverlay(unsigned int id) {
|
|||
if (thisOverlay) {
|
||||
unsigned int cloneId = addOverlay(Overlay::Pointer(thisOverlay->createClone()));
|
||||
auto attachable = std::dynamic_pointer_cast<PanelAttachable>(thisOverlay);
|
||||
if (attachable && attachable->getAttachedPanel()) {
|
||||
attachable->getAttachedPanel()->addChild(cloneId);
|
||||
if (attachable && attachable->getParentPanel()) {
|
||||
attachable->getParentPanel()->addChild(cloneId);
|
||||
}
|
||||
return cloneId;
|
||||
}
|
||||
|
@ -258,9 +258,9 @@ void Overlays::deleteOverlay(unsigned int id) {
|
|||
}
|
||||
|
||||
auto attachable = std::dynamic_pointer_cast<PanelAttachable>(overlayToDelete);
|
||||
if (attachable && attachable->getAttachedPanel()) {
|
||||
attachable->getAttachedPanel()->removeChild(id);
|
||||
attachable->setAttachedPanel(nullptr);
|
||||
if (attachable && attachable->getParentPanel()) {
|
||||
attachable->getParentPanel()->removeChild(id);
|
||||
attachable->setParentPanel(nullptr);
|
||||
}
|
||||
|
||||
QWriteLocker lock(&_deleteLock);
|
||||
|
@ -277,29 +277,29 @@ QString Overlays::getOverlayType(unsigned int overlayId) const {
|
|||
return "";
|
||||
}
|
||||
|
||||
unsigned int Overlays::getAttachedPanel(unsigned int childId) const {
|
||||
unsigned int Overlays::getParentPanel(unsigned int childId) const {
|
||||
Overlay::Pointer overlay = getOverlay(childId);
|
||||
auto attachable = std::dynamic_pointer_cast<PanelAttachable>(overlay);
|
||||
if (attachable) {
|
||||
return _panels.key(attachable->getAttachedPanel());
|
||||
return _panels.key(attachable->getParentPanel());
|
||||
} else if (_panels.contains(childId)) {
|
||||
return _panels.key(getPanel(childId)->getAttachedPanel());
|
||||
return _panels.key(getPanel(childId)->getParentPanel());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Overlays::setAttachedPanel(unsigned int childId, unsigned int panelId) {
|
||||
void Overlays::setParentPanel(unsigned int childId, unsigned int panelId) {
|
||||
auto attachable = std::dynamic_pointer_cast<PanelAttachable>(getOverlay(childId));
|
||||
if (attachable) {
|
||||
if (_panels.contains(panelId)) {
|
||||
auto panel = getPanel(panelId);
|
||||
panel->addChild(childId);
|
||||
attachable->setAttachedPanel(panel);
|
||||
attachable->setParentPanel(panel);
|
||||
} else {
|
||||
auto panel = attachable->getAttachedPanel();
|
||||
auto panel = attachable->getParentPanel();
|
||||
if (panel) {
|
||||
panel->removeChild(childId);
|
||||
attachable->setAttachedPanel(nullptr);
|
||||
attachable->setParentPanel(nullptr);
|
||||
}
|
||||
}
|
||||
} else if (_panels.contains(childId)) {
|
||||
|
@ -307,12 +307,12 @@ void Overlays::setAttachedPanel(unsigned int childId, unsigned int panelId) {
|
|||
if (_panels.contains(panelId)) {
|
||||
auto panel = getPanel(panelId);
|
||||
panel->addChild(childId);
|
||||
child->setAttachedPanel(panel);
|
||||
child->setParentPanel(panel);
|
||||
} else {
|
||||
auto panel = child->getAttachedPanel();
|
||||
auto panel = child->getParentPanel();
|
||||
if (panel) {
|
||||
panel->removeChild(childId);
|
||||
child->setAttachedPanel(0);
|
||||
child->setParentPanel(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ public slots:
|
|||
/// get the string type of the overlay used in addOverlay
|
||||
QString getOverlayType(unsigned int overlayId) const;
|
||||
|
||||
unsigned int getAttachedPanel(unsigned int childId) const;
|
||||
void setAttachedPanel(unsigned int childId, unsigned int panelId);
|
||||
unsigned int getParentPanel(unsigned int childId) const;
|
||||
void setParentPanel(unsigned int childId, unsigned int panelId);
|
||||
|
||||
/// returns the top most 2D overlay at the screen point, or 0 if not overlay at that point
|
||||
unsigned int getOverlayAtPoint(const glm::vec2& point);
|
||||
|
|
|
@ -14,33 +14,33 @@
|
|||
#include <RegisteredMetaTypes.h>
|
||||
|
||||
PanelAttachable::PanelAttachable() :
|
||||
_attachedPanel(nullptr),
|
||||
_parentPanel(nullptr),
|
||||
_offsetPosition(0, 0, 0),
|
||||
_offsetRotation(1, 0, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
PanelAttachable::PanelAttachable(const PanelAttachable* panelAttachable) :
|
||||
_attachedPanel(panelAttachable->_attachedPanel),
|
||||
_parentPanel(panelAttachable->_parentPanel),
|
||||
_offsetPosition(panelAttachable->_offsetPosition),
|
||||
_offsetRotation(panelAttachable->_offsetRotation)
|
||||
{
|
||||
}
|
||||
|
||||
bool PanelAttachable::getParentVisible() const {
|
||||
if (getAttachedPanel()) {
|
||||
return getAttachedPanel()->getVisible() && getAttachedPanel()->getParentVisible();
|
||||
if (getParentPanel()) {
|
||||
return getParentPanel()->getVisible() && getParentPanel()->getParentVisible();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void PanelAttachable::setTransforms(Transform& transform) {
|
||||
if (getAttachedPanel()) {
|
||||
transform.setTranslation(getAttachedPanel()->getComputedPosition());
|
||||
transform.setRotation(getAttachedPanel()->getComputedRotation());
|
||||
transform.postTranslate(getAttachedPanel()->getOffsetPosition());
|
||||
transform.postRotate(getAttachedPanel()->getFacingRotation());
|
||||
void PanelAttachable::applyTransformTo(Transform& transform) {
|
||||
if (getParentPanel()) {
|
||||
transform.setTranslation(getParentPanel()->getComputedPosition());
|
||||
transform.setRotation(getParentPanel()->getComputedRotation());
|
||||
transform.postTranslate(getParentPanel()->getOffsetPosition());
|
||||
transform.postRotate(getParentPanel()->getFacingRotation());
|
||||
transform.postTranslate(getOffsetPosition());
|
||||
transform.postRotate(getFacingRotation());
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ public:
|
|||
PanelAttachable();
|
||||
PanelAttachable(const PanelAttachable* panelAttachable);
|
||||
|
||||
OverlayPanel::Pointer getAttachedPanel() const { return _attachedPanel; }
|
||||
OverlayPanel::Pointer getParentPanel() const { return _parentPanel; }
|
||||
virtual glm::vec3 getOffsetPosition() const { return _offsetPosition; }
|
||||
virtual glm::quat getFacingRotation() const { return _offsetRotation; }
|
||||
bool getParentVisible() const;
|
||||
|
||||
void setAttachedPanel(OverlayPanel::Pointer panel) { _attachedPanel = panel; }
|
||||
void setParentPanel(OverlayPanel::Pointer panel) { _parentPanel = panel; }
|
||||
virtual void setOffsetPosition(const glm::vec3& position) { _offsetPosition = position; }
|
||||
virtual void setFacingRotation(const glm::quat& rotation) { _offsetRotation = rotation; }
|
||||
|
||||
|
@ -35,12 +35,12 @@ public:
|
|||
void setProperties(const QScriptValue& properties);
|
||||
|
||||
protected:
|
||||
virtual void setTransforms(Transform& transform);
|
||||
virtual void applyTransformTo(Transform& transform);
|
||||
|
||||
private:
|
||||
OverlayPanel::Pointer _attachedPanel;
|
||||
glm::vec3 _offsetPosition;
|
||||
glm::quat _offsetRotation;
|
||||
OverlayPanel::Pointer _parentPanel;// = nullptr;
|
||||
glm::vec3 _offsetPosition;// = {0, 0, 0};
|
||||
glm::quat _offsetRotation;// = {1, 0, 0, 0};
|
||||
};
|
||||
|
||||
#endif // hifi_PanelAttachable_h
|
||||
|
|
|
@ -75,7 +75,7 @@ xColor Text3DOverlay::getBackgroundColor() {
|
|||
}
|
||||
|
||||
void Text3DOverlay::update(float deltatime) {
|
||||
setTransforms(_transform);
|
||||
applyTransformTo(_transform);
|
||||
}
|
||||
|
||||
void Text3DOverlay::render(RenderArgs* args) {
|
||||
|
@ -86,7 +86,7 @@ void Text3DOverlay::render(RenderArgs* args) {
|
|||
Q_ASSERT(args->_batch);
|
||||
auto& batch = *args->_batch;
|
||||
|
||||
setTransforms(_transform);
|
||||
applyTransformTo(_transform);
|
||||
batch.setModelTransform(_transform);
|
||||
|
||||
const float MAX_COLOR = 255.0f;
|
||||
|
@ -212,6 +212,6 @@ QSizeF Text3DOverlay::textSize(const QString& text) const {
|
|||
}
|
||||
|
||||
bool Text3DOverlay::findRayIntersection(const glm::vec3 &origin, const glm::vec3 &direction, float &distance, BoxFace &face) {
|
||||
setTransforms(_transform);
|
||||
applyTransformTo(_transform);
|
||||
return Billboard3DOverlay::findRayIntersection(origin, direction, distance, face);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue