mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 17:41:12 +02:00
Merge pull request #3863 from huffman/overlay-front-draw
Overlay Front Draw
This commit is contained in:
commit
c4ea6bac1d
6 changed files with 47 additions and 9 deletions
|
@ -205,7 +205,7 @@ SelectionDisplay = (function () {
|
||||||
|
|
||||||
var MINIMUM_DIMENSION = 0.001;
|
var MINIMUM_DIMENSION = 0.001;
|
||||||
|
|
||||||
var GRABBER_DISTANCE_TO_SIZE_RATIO = 0.015;
|
var GRABBER_DISTANCE_TO_SIZE_RATIO = 0.0075;
|
||||||
|
|
||||||
var spaceMode = SPACE_LOCAL;
|
var spaceMode = SPACE_LOCAL;
|
||||||
var mode = "UNKNOWN";
|
var mode = "UNKNOWN";
|
||||||
|
@ -260,6 +260,7 @@ SelectionDisplay = (function () {
|
||||||
var grabberColorFace = { red: 120, green: 120, blue: 120 };
|
var grabberColorFace = { red: 120, green: 120, blue: 120 };
|
||||||
var grabberLineWidth = 0.5;
|
var grabberLineWidth = 0.5;
|
||||||
var grabberSolid = true;
|
var grabberSolid = true;
|
||||||
|
var grabberMoveUpPosition = { x: 0, y: 0, z: 0 };
|
||||||
|
|
||||||
var grabberPropertiesCorner = {
|
var grabberPropertiesCorner = {
|
||||||
position: { x:0, y: 0, z: 0},
|
position: { x:0, y: 0, z: 0},
|
||||||
|
@ -1093,7 +1094,8 @@ SelectionDisplay = (function () {
|
||||||
Overlays.editOverlay(grabberEdgeFL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeFL });
|
Overlays.editOverlay(grabberEdgeFL, { visible: stretchHandlesVisible, rotation: rotation, position: EdgeFL });
|
||||||
|
|
||||||
var grabberMoveUpOffset = 0.1;
|
var grabberMoveUpOffset = 0.1;
|
||||||
Overlays.editOverlay(grabberMoveUp, { visible: activeTool == null || mode == "TRANSLATE_UP_DOWN", position: { x: position.x, y: position.y + worldTop + grabberMoveUpOffset, z: position.z } });
|
grabberMoveUpPosition = { x: position.x, y: position.y + worldTop + grabberMoveUpOffset, z: position.z }
|
||||||
|
Overlays.editOverlay(grabberMoveUp, { visible: activeTool == null || mode == "TRANSLATE_UP_DOWN" });
|
||||||
};
|
};
|
||||||
|
|
||||||
that.setOverlaysVisible = function(isVisible) {
|
that.setOverlaysVisible = function(isVisible) {
|
||||||
|
@ -2297,8 +2299,10 @@ SelectionDisplay = (function () {
|
||||||
Overlays.editOverlay(rollHandle, {
|
Overlays.editOverlay(rollHandle, {
|
||||||
scale: handleSize,
|
scale: handleSize,
|
||||||
});
|
});
|
||||||
|
var pos = Vec3.sum(grabberMoveUpPosition, { x: 0, y: Vec3.length(diff) * GRABBER_DISTANCE_TO_SIZE_RATIO * 3, z: 0 });
|
||||||
Overlays.editOverlay(grabberMoveUp, {
|
Overlays.editOverlay(grabberMoveUp, {
|
||||||
scale: handleSize,
|
position: pos,
|
||||||
|
scale: handleSize / 2,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2836,7 +2836,12 @@ void Application::updateShadowMap() {
|
||||||
// render JS/scriptable overlays
|
// render JS/scriptable overlays
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("3dOverlays");
|
PerformanceTimer perfTimer("3dOverlays");
|
||||||
_overlays.render3D(RenderArgs::SHADOW_RENDER_MODE);
|
_overlays.render3D(false, RenderArgs::SHADOW_RENDER_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
PerformanceTimer perfTimer("3dOverlaysFront");
|
||||||
|
_overlays.render3D(true, RenderArgs::SHADOW_RENDER_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
@ -3051,7 +3056,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
||||||
// render JS/scriptable overlays
|
// render JS/scriptable overlays
|
||||||
{
|
{
|
||||||
PerformanceTimer perfTimer("3dOverlays");
|
PerformanceTimer perfTimer("3dOverlays");
|
||||||
_overlays.render3D();
|
_overlays.render3D(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// render the ambient occlusion effect if enabled
|
// render the ambient occlusion effect if enabled
|
||||||
|
@ -3135,6 +3140,13 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::Wireframe)) {
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render 3D overlays that should be drawn in front
|
||||||
|
{
|
||||||
|
PerformanceTimer perfTimer("3dOverlaysFront");
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
_overlays.render3D(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) {
|
void Application::updateUntranslatedViewMatrix(const glm::vec3& viewMatrixTranslation) {
|
||||||
|
|
|
@ -27,7 +27,8 @@ Base3DOverlay::Base3DOverlay() :
|
||||||
_rotation(),
|
_rotation(),
|
||||||
_isSolid(DEFAULT_IS_SOLID),
|
_isSolid(DEFAULT_IS_SOLID),
|
||||||
_isDashedLine(DEFAULT_IS_DASHED_LINE),
|
_isDashedLine(DEFAULT_IS_DASHED_LINE),
|
||||||
_ignoreRayIntersection(false)
|
_ignoreRayIntersection(false),
|
||||||
|
_drawInFront(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +49,13 @@ Base3DOverlay::~Base3DOverlay() {
|
||||||
void Base3DOverlay::setProperties(const QScriptValue& properties) {
|
void Base3DOverlay::setProperties(const QScriptValue& properties) {
|
||||||
Overlay::setProperties(properties);
|
Overlay::setProperties(properties);
|
||||||
|
|
||||||
|
QScriptValue drawInFront = properties.property("drawInFront");
|
||||||
|
|
||||||
|
if (drawInFront.isValid()) {
|
||||||
|
bool value = drawInFront.toVariant().toBool();
|
||||||
|
setDrawInFront(value);
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValue position = properties.property("position");
|
QScriptValue position = properties.property("position");
|
||||||
|
|
||||||
// if "position" property was not there, check to see if they included aliases: start, point, p1
|
// if "position" property was not there, check to see if they included aliases: start, point, p1
|
||||||
|
@ -151,6 +159,9 @@ QScriptValue Base3DOverlay::getProperty(const QString& property) {
|
||||||
if (property == "ignoreRayIntersection") {
|
if (property == "ignoreRayIntersection") {
|
||||||
return _ignoreRayIntersection;
|
return _ignoreRayIntersection;
|
||||||
}
|
}
|
||||||
|
if (property == "drawInFront") {
|
||||||
|
return _drawInFront;
|
||||||
|
}
|
||||||
|
|
||||||
return Overlay::getProperty(property);
|
return Overlay::getProperty(property);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
bool getIsSolidLine() const { return !_isDashedLine; }
|
bool getIsSolidLine() const { return !_isDashedLine; }
|
||||||
const glm::quat& getRotation() const { return _rotation; }
|
const glm::quat& getRotation() const { return _rotation; }
|
||||||
bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; }
|
bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; }
|
||||||
|
bool getDrawInFront() const { return _drawInFront; }
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void setPosition(const glm::vec3& position) { _position = position; }
|
void setPosition(const glm::vec3& position) { _position = position; }
|
||||||
|
@ -44,6 +45,7 @@ public:
|
||||||
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
|
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
|
||||||
void setRotation(const glm::quat& value) { _rotation = value; }
|
void setRotation(const glm::quat& value) { _rotation = value; }
|
||||||
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
|
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
|
||||||
|
void setDrawInFront(bool value) { _drawInFront = value; }
|
||||||
|
|
||||||
virtual void setProperties(const QScriptValue& properties);
|
virtual void setProperties(const QScriptValue& properties);
|
||||||
virtual QScriptValue getProperty(const QString& property);
|
virtual QScriptValue getProperty(const QString& property);
|
||||||
|
@ -64,6 +66,7 @@ protected:
|
||||||
bool _isSolid;
|
bool _isSolid;
|
||||||
bool _isDashedLine;
|
bool _isDashedLine;
|
||||||
bool _ignoreRayIntersection;
|
bool _ignoreRayIntersection;
|
||||||
|
bool _drawInFront;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Base3DOverlay_h
|
#endif // hifi_Base3DOverlay_h
|
||||||
|
|
|
@ -93,7 +93,7 @@ void Overlays::render2D() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlays::render3D(RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
|
void Overlays::render3D(bool drawFront, RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
|
||||||
QReadLocker lock(&_lock);
|
QReadLocker lock(&_lock);
|
||||||
if (_overlays3D.size() == 0) {
|
if (_overlays3D.size() == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -112,6 +112,10 @@ void Overlays::render3D(RenderArgs::RenderMode renderMode, RenderArgs::RenderSid
|
||||||
|
|
||||||
|
|
||||||
foreach(Overlay* thisOverlay, _overlays3D) {
|
foreach(Overlay* thisOverlay, _overlays3D) {
|
||||||
|
Base3DOverlay* overlay3D = static_cast<Base3DOverlay*>(thisOverlay);
|
||||||
|
if (overlay3D->getDrawInFront() != drawFront) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
switch (thisOverlay->getAnchor()) {
|
switch (thisOverlay->getAnchor()) {
|
||||||
case Overlay::MY_AVATAR:
|
case Overlay::MY_AVATAR:
|
||||||
|
@ -301,6 +305,7 @@ void OverlayPropertyResultFromScriptValue(const QScriptValue& value, OverlayProp
|
||||||
|
|
||||||
RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray) {
|
RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray) {
|
||||||
float bestDistance = std::numeric_limits<float>::max();
|
float bestDistance = std::numeric_limits<float>::max();
|
||||||
|
bool bestIsFront = false;
|
||||||
RayToOverlayIntersectionResult result;
|
RayToOverlayIntersectionResult result;
|
||||||
QMapIterator<unsigned int, Overlay*> i(_overlays3D);
|
QMapIterator<unsigned int, Overlay*> i(_overlays3D);
|
||||||
i.toBack();
|
i.toBack();
|
||||||
|
@ -313,7 +318,9 @@ RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray)
|
||||||
BoxFace thisFace;
|
BoxFace thisFace;
|
||||||
QString thisExtraInfo;
|
QString thisExtraInfo;
|
||||||
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance, thisFace, thisExtraInfo)) {
|
if (thisOverlay->findRayIntersectionExtraInfo(ray.origin, ray.direction, thisDistance, thisFace, thisExtraInfo)) {
|
||||||
if (thisDistance < bestDistance) {
|
bool isDrawInFront = thisOverlay->getDrawInFront();
|
||||||
|
if (thisDistance < bestDistance && (!bestIsFront || isDrawInFront)) {
|
||||||
|
bestIsFront = isDrawInFront;
|
||||||
bestDistance = thisDistance;
|
bestDistance = thisDistance;
|
||||||
result.intersects = true;
|
result.intersects = true;
|
||||||
result.distance = thisDistance;
|
result.distance = thisDistance;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
|
#include <QSignalMapper>
|
||||||
|
|
||||||
#include "Overlay.h"
|
#include "Overlay.h"
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ public:
|
||||||
~Overlays();
|
~Overlays();
|
||||||
void init(QGLWidget* parent);
|
void init(QGLWidget* parent);
|
||||||
void update(float deltatime);
|
void update(float deltatime);
|
||||||
void render3D(RenderArgs::RenderMode renderMode = RenderArgs::DEFAULT_RENDER_MODE,
|
void render3D(bool drawFront, RenderArgs::RenderMode renderMode = RenderArgs::DEFAULT_RENDER_MODE,
|
||||||
RenderArgs::RenderSide renderSide = RenderArgs::MONO);
|
RenderArgs::RenderSide renderSide = RenderArgs::MONO);
|
||||||
void render2D();
|
void render2D();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue