Rename 2D -> HUD, 3D -> World in Overlays

This commit is contained in:
Ryan Huffman 2014-12-30 14:50:17 -08:00
parent 468c564566
commit 2b835e621c
8 changed files with 86 additions and 88 deletions

View file

@ -461,7 +461,7 @@ CameraTool = function(cameraManager) {
color: { red: 255, green: 0, blue: 0 },
solid: true,
visible: true,
drawOnApplicationOverlay: true,
drawOnHUD: true,
};
var defaultLineProps = {
lineWidth: 1.5,
@ -471,7 +471,7 @@ CameraTool = function(cameraManager) {
end: { x: 0, y: 0, z: 0 },
color: { red: 255, green: 0, blue: 0 },
visible: true,
drawOnApplicationOverlay: true,
drawOnHUD: true,
};
var orientationOverlay = OverlayGroup({

View file

@ -2896,12 +2896,12 @@ void Application::updateShadowMap() {
// render JS/scriptable overlays
{
PerformanceTimer perfTimer("3dOverlays");
_overlays.render3D(false, RenderArgs::SHADOW_RENDER_MODE);
_overlays.renderWorld(false, RenderArgs::SHADOW_RENDER_MODE);
}
{
PerformanceTimer perfTimer("3dOverlaysFront");
_overlays.render3D(true, RenderArgs::SHADOW_RENDER_MODE);
_overlays.renderWorld(true, RenderArgs::SHADOW_RENDER_MODE);
}
glDisable(GL_POLYGON_OFFSET_FILL);
@ -3129,7 +3129,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
// render JS/scriptable overlays
{
PerformanceTimer perfTimer("3dOverlays");
_overlays.render3D(false);
_overlays.renderWorld(false);
}
// render the ambient occlusion effect if enabled
@ -3218,7 +3218,7 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly, RenderAr
{
PerformanceTimer perfTimer("3dOverlaysFront");
glClear(GL_DEPTH_BUFFER_BIT);
_overlays.render3D(true);
_overlays.renderWorld(true);
}
}

View file

@ -195,7 +195,7 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
// give external parties a change to hook in
emit application->renderingOverlay();
overlays.render2D();
overlays.renderHUD();
renderPointers();

View file

@ -29,7 +29,7 @@ Base3DOverlay::Base3DOverlay() :
_isDashedLine(DEFAULT_IS_DASHED_LINE),
_ignoreRayIntersection(false),
_drawInFront(false),
_drawOnApplicationOverlay(false)
_drawOnHUD(false)
{
}
@ -57,11 +57,11 @@ void Base3DOverlay::setProperties(const QScriptValue& properties) {
setDrawInFront(value);
}
QScriptValue drawOnApplicationOverlay = properties.property("drawOnApplicationOverlay");
QScriptValue drawOnHUD = properties.property("drawOnHUD");
if (drawOnApplicationOverlay.isValid()) {
bool value = drawOnApplicationOverlay.toVariant().toBool();
setDrawOnApplicationOverlay(value);
if (drawOnHUD.isValid()) {
bool value = drawOnHUD.toVariant().toBool();
setDrawOnHUD(value);
}
QScriptValue position = properties.property("position");
@ -167,8 +167,8 @@ QScriptValue Base3DOverlay::getProperty(const QString& property) {
if (property == "drawInFront") {
return _drawInFront;
}
if (property == "drawOnApplicationOverlay") {
return _drawOnApplicationOverlay;
if (property == "drawOnHUD") {
return _drawOnHUD;
}
return Overlay::getProperty(property);

View file

@ -37,7 +37,7 @@ public:
const glm::quat& getRotation() const { return _rotation; }
bool getIgnoreRayIntersection() const { return _ignoreRayIntersection; }
bool getDrawInFront() const { return _drawInFront; }
bool getDrawOnApplicationOverlay() const { return _drawOnApplicationOverlay; }
bool getDrawOnHUD() const { return _drawOnHUD; }
// setters
void setPosition(const glm::vec3& position) { _position = position; }
@ -47,7 +47,7 @@ public:
void setRotation(const glm::quat& value) { _rotation = value; }
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
void setDrawInFront(bool value) { _drawInFront = value; }
void setDrawOnApplicationOverlay(bool value) { _drawOnApplicationOverlay = value; }
void setDrawOnHUD(bool value) { _drawOnHUD = value; }
virtual void setProperties(const QScriptValue& properties);
virtual QScriptValue getProperty(const QString& property);
@ -69,7 +69,7 @@ protected:
bool _isDashedLine;
bool _ignoreRayIntersection;
bool _drawInFront;
bool _drawOnApplicationOverlay;
bool _drawOnHUD;
};
#endif // hifi_Base3DOverlay_h

View file

@ -77,7 +77,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
glColor4f(1.0f, 1.0f, 1.0f, alpha);
glScalef(dimensions.x * _borderSize, dimensions.y * _borderSize, dimensions.z * _borderSize);
if (_drawOnApplicationOverlay) {
if (_drawOnHUD) {
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
} else {
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);
@ -90,7 +90,7 @@ void Cube3DOverlay::render(RenderArgs* args) {
glPushMatrix();
glColor4f(color.red / MAX_COLOR, color.green / MAX_COLOR, color.blue / MAX_COLOR, alpha);
glScalef(dimensions.x, dimensions.y, dimensions.z);
if (_drawOnApplicationOverlay) {
if (_drawOnHUD) {
DependencyManager::get<GeometryCache>()->renderSolidCube(1.0f);
} else {
DependencyManager::get<DeferredLightingEffect>()->renderSolidCube(1.0f);

View file

@ -37,14 +37,14 @@ Overlays::~Overlays() {
{
QWriteLocker lock(&_lock);
foreach(Overlay* thisOverlay, _overlays2D) {
foreach(Overlay* thisOverlay, _overlaysHUD) {
delete thisOverlay;
}
_overlays2D.clear();
foreach(Overlay* thisOverlay, _overlays3D) {
_overlaysHUD.clear();
foreach(Overlay* thisOverlay, _overlaysWorld) {
delete thisOverlay;
}
_overlays3D.clear();
_overlaysWorld.clear();
}
if (!_overlaysToDelete.isEmpty()) {
@ -65,10 +65,10 @@ void Overlays::update(float deltatime) {
{
QWriteLocker lock(&_lock);
foreach(Overlay* thisOverlay, _overlays2D) {
foreach(Overlay* thisOverlay, _overlaysHUD) {
thisOverlay->update(deltatime);
}
foreach(Overlay* thisOverlay, _overlays3D) {
foreach(Overlay* thisOverlay, _overlaysWorld) {
thisOverlay->update(deltatime);
}
}
@ -82,32 +82,32 @@ void Overlays::update(float deltatime) {
}
void Overlays::render2D() {
void Overlays::renderHUD() {
QReadLocker lock(&_lock);
RenderArgs args = { NULL, Application::getInstance()->getViewFrustum(),
Menu::getInstance()->getVoxelSizeScale(), Menu::getInstance()->getBoundaryLevelAdjust(),
RenderArgs::DEFAULT_RENDER_MODE, RenderArgs::MONO, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
foreach(Overlay* thisOverlay, _overlays2D) {
thisOverlay->render(&args);
}
foreach(Overlay* thisOverlay, _overlaysHUD) {
if (thisOverlay->is3D()) {
qDebug() << "Rendering 3d HUD!";
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
foreach(Overlay* thisOverlay, _overlays3D) {
Base3DOverlay* overlay3D = static_cast<Base3DOverlay*>(thisOverlay);
if (overlay3D->getDrawOnApplicationOverlay()) {
thisOverlay->render(&args);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
} else{
thisOverlay->render(&args);
}
}
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
}
void Overlays::render3D(bool drawFront, RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
void Overlays::renderWorld(bool drawFront, RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
QReadLocker lock(&_lock);
if (_overlays3D.size() == 0) {
if (_overlaysWorld.size() == 0) {
return;
}
bool myAvatarComputed = false;
@ -123,9 +123,9 @@ void Overlays::render3D(bool drawFront, RenderArgs::RenderMode renderMode, Rende
renderMode, renderSide, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
foreach(Overlay* thisOverlay, _overlays3D) {
foreach(Overlay* thisOverlay, _overlaysWorld) {
Base3DOverlay* overlay3D = static_cast<Base3DOverlay*>(thisOverlay);
if (overlay3D->getDrawInFront() != drawFront || overlay3D->getDrawOnApplicationOverlay()) {
if (overlay3D->getDrawInFront() != drawFront) {
continue;
}
glPushMatrix();
@ -204,9 +204,14 @@ unsigned int Overlays::addOverlay(Overlay* overlay) {
unsigned int thisID = _nextOverlayID;
_nextOverlayID++;
if (overlay->is3D()) {
_overlays3D[thisID] = overlay;
Base3DOverlay* overlay3D = static_cast<Base3DOverlay*>(overlay);
if (overlay3D->getDrawOnHUD()) {
_overlaysHUD[thisID] = overlay;
} else {
_overlaysWorld[thisID] = overlay;
}
} else {
_overlays2D[thisID] = overlay;
_overlaysHUD[thisID] = overlay;
}
return thisID;
@ -214,10 +219,10 @@ unsigned int Overlays::addOverlay(Overlay* overlay) {
unsigned int Overlays::cloneOverlay(unsigned int id) {
Overlay* thisOverlay = NULL;
if (_overlays2D.contains(id)) {
thisOverlay = _overlays2D[id];
} else if (_overlays3D.contains(id)) {
thisOverlay = _overlays3D[id];
if (_overlaysHUD.contains(id)) {
thisOverlay = _overlaysHUD[id];
} else if (_overlaysWorld.contains(id)) {
thisOverlay = _overlaysWorld[id];
}
return addOverlay(thisOverlay->createClone());
}
@ -225,10 +230,10 @@ unsigned int Overlays::cloneOverlay(unsigned int id) {
bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
Overlay* thisOverlay = NULL;
QWriteLocker lock(&_lock);
if (_overlays2D.contains(id)) {
thisOverlay = _overlays2D[id];
} else if (_overlays3D.contains(id)) {
thisOverlay = _overlays3D[id];
if (_overlaysHUD.contains(id)) {
thisOverlay = _overlaysHUD[id];
} else if (_overlaysWorld.contains(id)) {
thisOverlay = _overlaysWorld[id];
}
if (thisOverlay) {
thisOverlay->setProperties(properties);
@ -242,10 +247,10 @@ void Overlays::deleteOverlay(unsigned int id) {
{
QWriteLocker lock(&_lock);
if (_overlays2D.contains(id)) {
overlayToDelete = _overlays2D.take(id);
} else if (_overlays3D.contains(id)) {
overlayToDelete = _overlays3D.take(id);
if (_overlaysHUD.contains(id)) {
overlayToDelete = _overlaysHUD.take(id);
} else if (_overlaysWorld.contains(id)) {
overlayToDelete = _overlaysWorld.take(id);
} else {
return;
}
@ -262,7 +267,7 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
}
QReadLocker lock(&_lock);
QMapIterator<unsigned int, Overlay*> i(_overlays3D);
QMapIterator<unsigned int, Overlay*> i(_overlaysHUD);
i.toBack();
const float LARGE_NEGATIVE_FLOAT = -9999999;
@ -274,26 +279,22 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
while (i.hasPrevious()) {
i.previous();
unsigned int thisID = i.key();
Base3DOverlay* thisOverlay = static_cast<Base3DOverlay*>(i.value());
if (thisOverlay->getDrawOnApplicationOverlay() && !thisOverlay->getIgnoreRayIntersection()) {
if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace)) {
if (i.value()->is3D()) {
Base3DOverlay* thisOverlay = static_cast<Base3DOverlay*>(i.value());
if (thisOverlay->getDrawOnHUD() && !thisOverlay->getIgnoreRayIntersection()) {
if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace)) {
return thisID;
}
}
} else {
Overlay2D* thisOverlay = static_cast<Overlay2D*>(i.value());
if (thisOverlay->getVisible() && thisOverlay->isLoaded() &&
thisOverlay->getBounds().contains(pointCopy.x, pointCopy.y, false)) {
return thisID;
}
}
}
i = QMapIterator<unsigned int, Overlay*>(_overlays2D);
i.toBack();
while (i.hasPrevious()) {
i.previous();
unsigned int thisID = i.key();
Overlay2D* thisOverlay = static_cast<Overlay2D*>(i.value());
if (thisOverlay->getVisible() && thisOverlay->isLoaded() &&
thisOverlay->getBounds().contains(pointCopy.x, pointCopy.y, false)) {
return thisID;
}
}
return 0; // not found
}
@ -301,10 +302,10 @@ OverlayPropertyResult Overlays::getProperty(unsigned int id, const QString& prop
OverlayPropertyResult result;
Overlay* thisOverlay = NULL;
QReadLocker lock(&_lock);
if (_overlays2D.contains(id)) {
thisOverlay = _overlays2D[id];
} else if (_overlays3D.contains(id)) {
thisOverlay = _overlays3D[id];
if (_overlaysHUD.contains(id)) {
thisOverlay = _overlaysHUD[id];
} else if (_overlaysWorld.contains(id)) {
thisOverlay = _overlaysWorld[id];
}
if (thisOverlay) {
result.value = thisOverlay->getProperty(property);
@ -346,15 +347,12 @@ RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray)
float bestDistance = std::numeric_limits<float>::max();
bool bestIsFront = false;
RayToOverlayIntersectionResult result;
QMapIterator<unsigned int, Overlay*> i(_overlays3D);
QMapIterator<unsigned int, Overlay*> i(_overlaysWorld);
i.toBack();
while (i.hasPrevious()) {
i.previous();
unsigned int thisID = i.key();
Base3DOverlay* thisOverlay = static_cast<Base3DOverlay*>(i.value());
if (thisOverlay->getDrawOnApplicationOverlay()) {
continue;
}
if (thisOverlay->getVisible() && !thisOverlay->getIgnoreRayIntersection() && thisOverlay->isLoaded()) {
float thisDistance;
BoxFace thisFace;
@ -457,10 +455,10 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
bool Overlays::isLoaded(unsigned int id) {
QReadLocker lock(&_lock);
Overlay* thisOverlay = NULL;
if (_overlays2D.contains(id)) {
thisOverlay = _overlays2D[id];
} else if (_overlays3D.contains(id)) {
thisOverlay = _overlays3D[id];
if (_overlaysHUD.contains(id)) {
thisOverlay = _overlaysHUD[id];
} else if (_overlaysWorld.contains(id)) {
thisOverlay = _overlaysWorld[id];
} else {
return false; // not found
}
@ -468,13 +466,13 @@ bool Overlays::isLoaded(unsigned int id) {
}
QSizeF Overlays::textSize(unsigned int id, const QString& text) const {
Overlay* thisOverlay = _overlays2D[id];
Overlay* thisOverlay = _overlaysHUD[id];
if (thisOverlay) {
if (typeid(*thisOverlay) == typeid(TextOverlay)) {
return static_cast<TextOverlay*>(thisOverlay)->textSize(text);
}
} else {
thisOverlay = _overlays3D[id];
thisOverlay = _overlaysWorld[id];
if (thisOverlay) {
if (typeid(*thisOverlay) == typeid(Text3DOverlay)) {
return static_cast<Text3DOverlay*>(thisOverlay)->textSize(text);

View file

@ -52,9 +52,9 @@ public:
~Overlays();
void init(QGLWidget* parent);
void update(float deltatime);
void render3D(bool drawFront, RenderArgs::RenderMode renderMode = RenderArgs::DEFAULT_RENDER_MODE,
void renderWorld(bool drawFront, RenderArgs::RenderMode renderMode = RenderArgs::DEFAULT_RENDER_MODE,
RenderArgs::RenderSide renderSide = RenderArgs::MONO);
void render2D();
void renderHUD();
public slots:
/// adds an overlay with the specific properties
@ -90,8 +90,8 @@ public slots:
QSizeF textSize(unsigned int id, const QString& text) const;
private:
QMap<unsigned int, Overlay*> _overlays2D;
QMap<unsigned int, Overlay*> _overlays3D;
QMap<unsigned int, Overlay*> _overlaysHUD;
QMap<unsigned int, Overlay*> _overlaysWorld;
QList<Overlay*> _overlaysToDelete;
unsigned int _nextOverlayID;
QGLWidget* _parent;