mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 03:24:13 +02:00
Merge pull request #8465 from sethalves/fix-3d-overlay-lines
fix -- make 3d-line overlays work again
This commit is contained in:
commit
54a5bf3b23
2 changed files with 54 additions and 8 deletions
interface/src/ui/overlays
|
@ -23,6 +23,7 @@ Line3DOverlay::Line3DOverlay() :
|
|||
|
||||
Line3DOverlay::Line3DOverlay(const Line3DOverlay* line3DOverlay) :
|
||||
Base3DOverlay(line3DOverlay),
|
||||
_start(line3DOverlay->_start),
|
||||
_end(line3DOverlay->_end),
|
||||
_geometryCacheID(DependencyManager::get<GeometryCache>()->allocateID())
|
||||
{
|
||||
|
@ -31,6 +32,40 @@ Line3DOverlay::Line3DOverlay(const Line3DOverlay* line3DOverlay) :
|
|||
Line3DOverlay::~Line3DOverlay() {
|
||||
}
|
||||
|
||||
glm::vec3 Line3DOverlay::getStart() const {
|
||||
bool success;
|
||||
glm::vec3 worldStart = localToWorld(_start, _parentID, _parentJointIndex, success);
|
||||
if (!success) {
|
||||
qDebug() << "Line3DOverlay::getStart failed";
|
||||
}
|
||||
return worldStart;
|
||||
}
|
||||
|
||||
glm::vec3 Line3DOverlay::getEnd() const {
|
||||
bool success;
|
||||
glm::vec3 worldEnd = localToWorld(_end, _parentID, _parentJointIndex, success);
|
||||
if (!success) {
|
||||
qDebug() << "Line3DOverlay::getEnd failed";
|
||||
}
|
||||
return worldEnd;
|
||||
}
|
||||
|
||||
void Line3DOverlay::setStart(const glm::vec3& start) {
|
||||
bool success;
|
||||
_start = worldToLocal(start, _parentID, _parentJointIndex, success);
|
||||
if (!success) {
|
||||
qDebug() << "Line3DOverlay::setStart failed";
|
||||
}
|
||||
}
|
||||
|
||||
void Line3DOverlay::setEnd(const glm::vec3& end) {
|
||||
bool success;
|
||||
_end = worldToLocal(end, _parentID, _parentJointIndex, success);
|
||||
if (!success) {
|
||||
qDebug() << "Line3DOverlay::setEnd failed";
|
||||
}
|
||||
}
|
||||
|
||||
AABox Line3DOverlay::getBounds() const {
|
||||
auto extents = Extents{};
|
||||
extents.addPoint(_start);
|
||||
|
@ -76,8 +111,8 @@ const render::ShapeKey Line3DOverlay::getShapeKey() {
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
void Line3DOverlay::setProperties(const QVariantMap& properties) {
|
||||
Base3DOverlay::setProperties(properties);
|
||||
void Line3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
||||
QVariantMap properties = originalProperties;
|
||||
|
||||
auto start = properties["start"];
|
||||
// if "start" property was not there, check to see if they included aliases: startPoint
|
||||
|
@ -87,6 +122,7 @@ void Line3DOverlay::setProperties(const QVariantMap& properties) {
|
|||
if (start.isValid()) {
|
||||
setStart(vec3FromVariant(start));
|
||||
}
|
||||
properties.remove("start"); // so that Base3DOverlay doesn't respond to it
|
||||
|
||||
auto end = properties["end"];
|
||||
// if "end" property was not there, check to see if they included aliases: endPoint
|
||||
|
@ -109,14 +145,16 @@ void Line3DOverlay::setProperties(const QVariantMap& properties) {
|
|||
if (glowWidth.isValid()) {
|
||||
setGlow(glowWidth.toFloat());
|
||||
}
|
||||
|
||||
Base3DOverlay::setProperties(properties);
|
||||
}
|
||||
|
||||
QVariant Line3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "start" || property == "startPoint" || property == "p1") {
|
||||
return vec3toVariant(_start);
|
||||
return vec3toVariant(getStart());
|
||||
}
|
||||
if (property == "end" || property == "endPoint" || property == "p2") {
|
||||
return vec3toVariant(_end);
|
||||
return vec3toVariant(getEnd());
|
||||
}
|
||||
|
||||
return Base3DOverlay::getProperty(property);
|
||||
|
@ -125,3 +163,8 @@ QVariant Line3DOverlay::getProperty(const QString& property) {
|
|||
Line3DOverlay* Line3DOverlay::createClone() const {
|
||||
return new Line3DOverlay(this);
|
||||
}
|
||||
|
||||
|
||||
void Line3DOverlay::locationChanged(bool tellPhysics) {
|
||||
// do nothing
|
||||
}
|
||||
|
|
|
@ -28,14 +28,15 @@ public:
|
|||
virtual AABox getBounds() const override;
|
||||
|
||||
// getters
|
||||
const glm::vec3& getStart() const { return _start; }
|
||||
const glm::vec3& getEnd() const { return _end; }
|
||||
glm::vec3 getStart() const;
|
||||
glm::vec3 getEnd() const;
|
||||
const float& getGlow() const { return _glow; }
|
||||
const float& getGlowWidth() const { return _glowWidth; }
|
||||
|
||||
// setters
|
||||
void setStart(const glm::vec3& start) { _start = start; }
|
||||
void setEnd(const glm::vec3& end) { _end = end; }
|
||||
void setStart(const glm::vec3& start);
|
||||
void setEnd(const glm::vec3& end);
|
||||
|
||||
void setGlow(const float& glow) { _glow = glow; }
|
||||
void setGlowWidth(const float& glowWidth) { _glowWidth = glowWidth; }
|
||||
|
||||
|
@ -44,6 +45,8 @@ public:
|
|||
|
||||
virtual Line3DOverlay* createClone() const override;
|
||||
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
|
||||
protected:
|
||||
glm::vec3 _start;
|
||||
glm::vec3 _end;
|
||||
|
|
Loading…
Reference in a new issue