mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-04 14:38:47 +02:00
fix circle3d overlays
This commit is contained in:
parent
ae625306ff
commit
16f545a9e8
6 changed files with 57 additions and 32 deletions
|
@ -61,8 +61,8 @@ public:
|
||||||
|
|
||||||
void notifyRenderVariableChange() const;
|
void notifyRenderVariableChange() const;
|
||||||
|
|
||||||
void setProperties(const QVariantMap& properties) override;
|
virtual void setProperties(const QVariantMap& properties) override;
|
||||||
QVariant getProperty(const QString& property) override;
|
virtual QVariant getProperty(const QString& property) override;
|
||||||
|
|
||||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||||
BoxFace& face, glm::vec3& surfaceNormal);
|
BoxFace& face, glm::vec3& surfaceNormal);
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
|
|
||||||
QString const Circle3DOverlay::TYPE = "circle3d";
|
QString const Circle3DOverlay::TYPE = "circle3d";
|
||||||
|
|
||||||
Circle3DOverlay::Circle3DOverlay() {
|
Circle3DOverlay::Circle3DOverlay() {}
|
||||||
memset(&_minorTickMarksColor, 0, sizeof(_minorTickMarksColor));
|
|
||||||
memset(&_majorTickMarksColor, 0, sizeof(_majorTickMarksColor));
|
|
||||||
}
|
|
||||||
|
|
||||||
Circle3DOverlay::Circle3DOverlay(const Circle3DOverlay* circle3DOverlay) :
|
Circle3DOverlay::Circle3DOverlay(const Circle3DOverlay* circle3DOverlay) :
|
||||||
Planar3DOverlay(circle3DOverlay),
|
Planar3DOverlay(circle3DOverlay),
|
||||||
|
@ -27,17 +24,21 @@ Circle3DOverlay::Circle3DOverlay(const Circle3DOverlay* circle3DOverlay) :
|
||||||
_endAt(circle3DOverlay->_endAt),
|
_endAt(circle3DOverlay->_endAt),
|
||||||
_outerRadius(circle3DOverlay->_outerRadius),
|
_outerRadius(circle3DOverlay->_outerRadius),
|
||||||
_innerRadius(circle3DOverlay->_innerRadius),
|
_innerRadius(circle3DOverlay->_innerRadius),
|
||||||
|
_innerStartColor(circle3DOverlay->_innerStartColor),
|
||||||
|
_innerEndColor(circle3DOverlay->_innerEndColor),
|
||||||
|
_outerStartColor(circle3DOverlay->_outerStartColor),
|
||||||
|
_outerEndColor(circle3DOverlay->_outerEndColor),
|
||||||
|
_innerStartAlpha(circle3DOverlay->_innerStartAlpha),
|
||||||
|
_innerEndAlpha(circle3DOverlay->_innerEndAlpha),
|
||||||
|
_outerStartAlpha(circle3DOverlay->_outerStartAlpha),
|
||||||
|
_outerEndAlpha(circle3DOverlay->_outerEndAlpha),
|
||||||
_hasTickMarks(circle3DOverlay->_hasTickMarks),
|
_hasTickMarks(circle3DOverlay->_hasTickMarks),
|
||||||
_majorTickMarksAngle(circle3DOverlay->_majorTickMarksAngle),
|
_majorTickMarksAngle(circle3DOverlay->_majorTickMarksAngle),
|
||||||
_minorTickMarksAngle(circle3DOverlay->_minorTickMarksAngle),
|
_minorTickMarksAngle(circle3DOverlay->_minorTickMarksAngle),
|
||||||
_majorTickMarksLength(circle3DOverlay->_majorTickMarksLength),
|
_majorTickMarksLength(circle3DOverlay->_majorTickMarksLength),
|
||||||
_minorTickMarksLength(circle3DOverlay->_minorTickMarksLength),
|
_minorTickMarksLength(circle3DOverlay->_minorTickMarksLength),
|
||||||
_majorTickMarksColor(circle3DOverlay->_majorTickMarksColor),
|
_majorTickMarksColor(circle3DOverlay->_majorTickMarksColor),
|
||||||
_minorTickMarksColor(circle3DOverlay->_minorTickMarksColor),
|
_minorTickMarksColor(circle3DOverlay->_minorTickMarksColor)
|
||||||
_quadVerticesID(GeometryCache::UNKNOWN_ID),
|
|
||||||
_lineVerticesID(GeometryCache::UNKNOWN_ID),
|
|
||||||
_majorTicksVerticesID(GeometryCache::UNKNOWN_ID),
|
|
||||||
_minorTicksVerticesID(GeometryCache::UNKNOWN_ID)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +81,8 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
||||||
|
|
||||||
Q_ASSERT(args->_batch);
|
Q_ASSERT(args->_batch);
|
||||||
auto& batch = *args->_batch;
|
auto& batch = *args->_batch;
|
||||||
if (args->_shapePipeline) {
|
|
||||||
batch.setPipeline(args->_shapePipeline->pipeline);
|
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, false, isTransparent(), false, !getIsSolid(), true);
|
||||||
}
|
|
||||||
|
|
||||||
batch.setModelTransform(getRenderTransform());
|
batch.setModelTransform(getRenderTransform());
|
||||||
|
|
||||||
|
@ -185,11 +185,10 @@ void Circle3DOverlay::render(RenderArgs* args) {
|
||||||
// for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise
|
// for our overlay, is solid means we draw a ring between the inner and outer radius of the circle, otherwise
|
||||||
// we just draw a line...
|
// we just draw a line...
|
||||||
if (getHasTickMarks()) {
|
if (getHasTickMarks()) {
|
||||||
|
if (!_majorTicksVerticesID) {
|
||||||
if (_majorTicksVerticesID == GeometryCache::UNKNOWN_ID) {
|
|
||||||
_majorTicksVerticesID = geometryCache->allocateID();
|
_majorTicksVerticesID = geometryCache->allocateID();
|
||||||
}
|
}
|
||||||
if (_minorTicksVerticesID == GeometryCache::UNKNOWN_ID) {
|
if (!_minorTicksVerticesID) {
|
||||||
_minorTicksVerticesID = geometryCache->allocateID();
|
_minorTicksVerticesID = geometryCache->allocateID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,6 +383,30 @@ QVariant Circle3DOverlay::getProperty(const QString& property) {
|
||||||
if (property == "innerRadius") {
|
if (property == "innerRadius") {
|
||||||
return _innerRadius;
|
return _innerRadius;
|
||||||
}
|
}
|
||||||
|
if (property == "innerStartColor") {
|
||||||
|
return xColorToVariant(_innerStartColor);
|
||||||
|
}
|
||||||
|
if (property == "innerEndColor") {
|
||||||
|
return xColorToVariant(_innerEndColor);
|
||||||
|
}
|
||||||
|
if (property == "outerStartColor") {
|
||||||
|
return xColorToVariant(_outerStartColor);
|
||||||
|
}
|
||||||
|
if (property == "outerEndColor") {
|
||||||
|
return xColorToVariant(_outerEndColor);
|
||||||
|
}
|
||||||
|
if (property == "innerStartAlpha") {
|
||||||
|
return _innerStartAlpha;
|
||||||
|
}
|
||||||
|
if (property == "innerEndAlpha") {
|
||||||
|
return _innerEndAlpha;
|
||||||
|
}
|
||||||
|
if (property == "outerStartAlpha") {
|
||||||
|
return _outerStartAlpha;
|
||||||
|
}
|
||||||
|
if (property == "outerEndAlpha") {
|
||||||
|
return _outerEndAlpha;
|
||||||
|
}
|
||||||
if (property == "hasTickMarks") {
|
if (property == "hasTickMarks") {
|
||||||
return _hasTickMarks;
|
return _hasTickMarks;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +432,6 @@ QVariant Circle3DOverlay::getProperty(const QString& property) {
|
||||||
return Planar3DOverlay::getProperty(property);
|
return Planar3DOverlay::getProperty(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
bool Circle3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||||
BoxFace& face, glm::vec3& surfaceNormal) {
|
BoxFace& face, glm::vec3& surfaceNormal) {
|
||||||
|
|
||||||
|
|
|
@ -65,22 +65,22 @@ protected:
|
||||||
float _outerRadius { 1 };
|
float _outerRadius { 1 };
|
||||||
float _innerRadius { 0 };
|
float _innerRadius { 0 };
|
||||||
|
|
||||||
xColor _innerStartColor;
|
xColor _innerStartColor { DEFAULT_OVERLAY_COLOR };
|
||||||
xColor _innerEndColor;
|
xColor _innerEndColor { DEFAULT_OVERLAY_COLOR };
|
||||||
xColor _outerStartColor;
|
xColor _outerStartColor { DEFAULT_OVERLAY_COLOR };
|
||||||
xColor _outerEndColor;
|
xColor _outerEndColor { DEFAULT_OVERLAY_COLOR };
|
||||||
float _innerStartAlpha;
|
float _innerStartAlpha { DEFAULT_ALPHA };
|
||||||
float _innerEndAlpha;
|
float _innerEndAlpha { DEFAULT_ALPHA };
|
||||||
float _outerStartAlpha;
|
float _outerStartAlpha { DEFAULT_ALPHA };
|
||||||
float _outerEndAlpha;
|
float _outerEndAlpha { DEFAULT_ALPHA };
|
||||||
|
|
||||||
bool _hasTickMarks { false };
|
bool _hasTickMarks { false };
|
||||||
float _majorTickMarksAngle { 0 };
|
float _majorTickMarksAngle { 0 };
|
||||||
float _minorTickMarksAngle { 0 };
|
float _minorTickMarksAngle { 0 };
|
||||||
float _majorTickMarksLength { 0 };
|
float _majorTickMarksLength { 0 };
|
||||||
float _minorTickMarksLength { 0 };
|
float _minorTickMarksLength { 0 };
|
||||||
xColor _majorTickMarksColor;
|
xColor _majorTickMarksColor { DEFAULT_OVERLAY_COLOR };
|
||||||
xColor _minorTickMarksColor;
|
xColor _minorTickMarksColor { DEFAULT_OVERLAY_COLOR };
|
||||||
gpu::Primitive _solidPrimitive { gpu::TRIANGLE_FAN };
|
gpu::Primitive _solidPrimitive { gpu::TRIANGLE_FAN };
|
||||||
int _quadVerticesID { 0 };
|
int _quadVerticesID { 0 };
|
||||||
int _lineVerticesID { 0 };
|
int _lineVerticesID { 0 };
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
static const xColor DEFAULT_OVERLAY_COLOR = { 255, 255, 255 };
|
const xColor Overlay::DEFAULT_OVERLAY_COLOR = { 255, 255, 255 };
|
||||||
static const float DEFAULT_ALPHA = 0.7f;
|
const float Overlay::DEFAULT_ALPHA = 0.7f;
|
||||||
|
|
||||||
Overlay::Overlay() :
|
Overlay::Overlay() :
|
||||||
_renderItemID(render::Item::INVALID_ITEM_ID),
|
_renderItemID(render::Item::INVALID_ITEM_ID),
|
||||||
|
|
|
@ -122,6 +122,9 @@ protected:
|
||||||
|
|
||||||
unsigned int _stackOrder { 0 };
|
unsigned int _stackOrder { 0 };
|
||||||
|
|
||||||
|
static const xColor DEFAULT_OVERLAY_COLOR;
|
||||||
|
static const float DEFAULT_ALPHA;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayID _overlayID; // only used for non-3d overlays
|
OverlayID _overlayID; // only used for non-3d overlays
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,8 +27,8 @@ public:
|
||||||
void setDimensions(float value) { setDimensions(glm::vec2(value)); }
|
void setDimensions(float value) { setDimensions(glm::vec2(value)); }
|
||||||
void setDimensions(const glm::vec2& value);
|
void setDimensions(const glm::vec2& value);
|
||||||
|
|
||||||
void setProperties(const QVariantMap& properties) override;
|
virtual void setProperties(const QVariantMap& properties) override;
|
||||||
QVariant getProperty(const QString& property) override;
|
virtual QVariant getProperty(const QString& property) override;
|
||||||
|
|
||||||
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
|
||||||
BoxFace& face, glm::vec3& surfaceNormal) override;
|
BoxFace& face, glm::vec3& surfaceNormal) override;
|
||||||
|
|
Loading…
Reference in a new issue