merging with upstream master and origin temp0

This commit is contained in:
Sam Gateau 2014-12-22 10:38:11 -08:00
commit 4c670ac17a
53 changed files with 286 additions and 240 deletions

View file

@ -12,6 +12,10 @@ if (POLICY CMP0043)
cmake_policy(SET CMP0043 OLD)
endif ()
if (POLICY CMP0042)
cmake_policy(SET CMP0042 OLD)
endif ()
project(hifi)
add_definitions(-DGLM_FORCE_RADIANS)

View file

@ -15,4 +15,4 @@ if (UNIX)
target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS})
endif (UNIX)
link_shared_dependencies()
include_dependency_includes()

View file

@ -1,5 +1,5 @@
#
# LinkSharedDependencies.cmake
# IncludeDependencyIncludes.cmake
# cmake/macros
#
# Copyright 2014 High Fidelity, Inc.
@ -9,7 +9,7 @@
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
macro(LINK_SHARED_DEPENDENCIES)
macro(INCLUDE_DEPENDENCY_INCLUDES)
if (${TARGET_NAME}_DEPENDENCY_INCLUDES)
list(REMOVE_DUPLICATES ${TARGET_NAME}_DEPENDENCY_INCLUDES)
@ -19,4 +19,4 @@ macro(LINK_SHARED_DEPENDENCIES)
# set the property on this target so it can be retreived by targets linking to us
set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_INCLUDES "${${TARGET_NAME}_DEPENDENCY_INCLUDES}")
endmacro(LINK_SHARED_DEPENDENCIES)
endmacro(INCLUDE_DEPENDENCY_INCLUDES)

View file

@ -1,47 +0,0 @@
#
# FindGLUT.cmake
#
# Try to find GLUT library and include path.
# Once done this will define
#
# GLUT_FOUND
# GLUT_INCLUDE_DIRS
# GLUT_LIBRARIES
#
# Created on 2/6/2014 by Stephen Birarda
# Copyright 2014 High Fidelity, Inc.
#
# Adapted from FindGLUT.cmake available in tlorach's OpenGLText Repository
# https://raw.github.com/tlorach/OpenGLText/master/cmake/FindGLUT.cmake
#
# Distributed under the Apache License, Version 2.0.
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
#
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
hifi_library_search_hints("freeglut")
if (WIN32)
set(GLUT_HINT_DIRS "${FREEGLUT_SEARCH_DIRS} ${OPENGL_INCLUDE_DIR}")
find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${FREEGLUT_SEARCH_DIRS})
find_library(GLUT_LIBRARY freeglut PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS})
else ()
find_path(GLUT_INCLUDE_DIRS GL/glut.h PATH_SUFFIXES include HINTS ${FREEGLUT_SEARCH_DIRS})
find_library(GLUT_LIBRARY glut PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS})
endif ()
include(FindPackageHandleStandardArgs)
set(GLUT_LIBRARIES "${GLUT_LIBRARY}" "${XMU_LIBRARY}" "${XI_LIBRARY}")
if (UNIX)
find_library(XI_LIBRARY Xi PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS})
find_library(XMU_LIBRARY Xmu PATH_SUFFIXES lib HINTS ${FREEGLUT_SEARCH_DIRS})
find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES XI_LIBRARY XMU_LIBRARY)
else ()
find_package_handle_standard_args(GLUT DEFAULT_MSG GLUT_INCLUDE_DIRS GLUT_LIBRARIES)
endif ()
mark_as_advanced(GLUT_INCLUDE_DIRS GLUT_LIBRARIES GLUT_LIBRARY XI_LIBRARY XMU_LIBRARY FREEGLUT_SEARCH_DIRS)

View file

@ -52,4 +52,4 @@ include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}")
# append OpenSSL to our list of libraries to link
target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES})
link_shared_dependencies()
include_dependency_includes()

View file

@ -15,3 +15,4 @@ Script.load("hydraMove.js");
Script.load("headMove.js");
Script.load("inspect.js");
Script.load("lobby.js");
Script.load("notifications.js");

View file

@ -13,34 +13,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function(){
this.oldColor = {};
this.oldColorKnown = false;
this.storeOldColor = function(entityID) {
var oldProperties = Entities.getEntityProperties(entityID);
this.oldColor = oldProperties.color;
this.oldColorKnown = true;
print("storing old color... this.oldColor=" + this.oldColor.red + "," + this.oldColor.green + "," + this.oldColor.blue);
};
this.preload = function(entityID) {
print("preload");
this.storeOldColor(entityID);
};
this.hoverEnterEntity = function(entityID, mouseEvent) {
print("hoverEnterEntity");
if (!this.oldColorKnown) {
this.storeOldColor(entityID);
}
Entities.editEntity(entityID, { color: { red: 0, green: 255, blue: 255} });
};
this.hoverLeaveEntity = function(entityID, mouseEvent) {
print("hoverLeaveEntity");
if (this.oldColorKnown) {
print("leave restoring old color... this.oldColor="
+ this.oldColor.red + "," + this.oldColor.green + "," + this.oldColor.blue);
Entities.editEntity(entityID, { color: this.oldColor });
}
};
})
(function() {
Script.include("changeColorOnHoverClass.js");
return new ChangeColorOnHover();
})

View file

@ -0,0 +1,55 @@
//
// changeColorOnHover.js
// examples/entityScripts
//
// Created by Brad Hefta-Gaub on 11/1/14.
// Copyright 2014 High Fidelity, Inc.
//
// This is an example of an entity script which when assigned to a non-model entity like a box or sphere, will
// change the color of the entity when you hover over it. This script uses the JavaScript prototype/class functionality
// to construct an object that has methods for hoverEnterEntity and hoverLeaveEntity;
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
ChangeColorOnHover = function(){
this.oldColor = {};
this.oldColorKnown = false;
};
ChangeColorOnHover.prototype = {
storeOldColor: function(entityID) {
var oldProperties = Entities.getEntityProperties(entityID);
this.oldColor = oldProperties.color;
this.oldColorKnown = true;
print("storing old color... this.oldColor=" + this.oldColor.red + "," + this.oldColor.green + "," + this.oldColor.blue);
},
preload: function(entityID) {
print("preload");
this.storeOldColor(entityID);
},
hoverEnterEntity: function(entityID, mouseEvent) {
print("hoverEnterEntity");
if (!this.oldColorKnown) {
this.storeOldColor(entityID);
}
Entities.editEntity(entityID, { color: { red: 0, green: 255, blue: 255} });
},
hoverLeaveEntity: function(entityID, mouseEvent) {
print("hoverLeaveEntity");
if (this.oldColorKnown) {
print("leave restoring old color... this.oldColor="
+ this.oldColor.red + "," + this.oldColor.green + "," + this.oldColor.blue);
Entities.editEntity(entityID, { color: this.oldColor });
}
}
};

View file

@ -27,10 +27,12 @@
};
this.enterEntity = function(entityID) {
print("enterEntity("+entityID.id+")");
playSound();
};
this.leaveEntity = function(entityID) {
print("leaveEntity("+entityID.id+")");
playSound();
};
})

View file

@ -6,4 +6,4 @@ setup_hifi_project(Network)
# link the shared hifi libraries
link_hifi_libraries(networking shared)
link_shared_dependencies()
include_dependency_includes()

View file

@ -25,15 +25,15 @@ else ()
endif ()
if (APPLE)
set(GL_HEADERS "#include <GLUT/glut.h>\n#include <OpenGL/glext.h>")
set(GL_HEADERS "#include <OpenGL/glext.h>")
elseif (UNIX)
# include the right GL headers for UNIX
set(GL_HEADERS "#include <GL/gl.h>\n#include <GL/glut.h>\n#include <GL/glext.h>")
set(GL_HEADERS "#include <GL/gl.h>\n#include <GL/glext.h>")
elseif (WIN32)
add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h
add_definitions(-DWINDOWS_LEAN_AND_MEAN) # needed to make sure windows doesn't go to crazy with its defines
set(GL_HEADERS "#include <windowshacks.h>\n#include <GL/glew.h>\n#include <GL/glut.h>\n#include <GL/wglew.h>")
set(GL_HEADERS "#include <windowshacks.h>\n#include <GL/glew.h>\n#include <GL/wglew.h>")
endif ()
# set up the external glm library
@ -194,11 +194,10 @@ if (APPLE)
# link in required OS X frameworks and include the right GL headers
find_library(CoreAudio CoreAudio)
find_library(CoreFoundation CoreFoundation)
find_library(GLUT GLUT)
find_library(OpenGL OpenGL)
find_library(AppKit AppKit)
target_link_libraries(${TARGET_NAME} ${CoreAudio} ${CoreFoundation} ${GLUT} ${OpenGL} ${AppKit})
target_link_libraries(${TARGET_NAME} ${CoreAudio} ${CoreFoundation} ${OpenGL} ${AppKit})
# install command for OS X bundle
INSTALL(TARGETS ${TARGET_NAME}
@ -214,15 +213,12 @@ else (APPLE)
)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}")
if (${OPENGL_INCLUDE_DIR})
include_directories(SYSTEM "${OPENGL_INCLUDE_DIR}")
endif ()
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}" "${GLUT_LIBRARIES}")
target_link_libraries(${TARGET_NAME} "${OPENGL_LIBRARY}")
# link target to external libraries
if (WIN32)
@ -232,7 +228,7 @@ else (APPLE)
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" wsock32.lib opengl32.lib)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" "${NSIGHT_LIBRARIES}" wsock32.lib opengl32.lib Winmm.lib)
# try to find the Nsight package and add it to the build if we find it
find_package(NSIGHT)
@ -246,4 +242,4 @@ else (APPLE)
endif (APPLE)
# link any dependencies bubbled up from our linked dependencies
link_shared_dependencies()
include_dependency_includes()

View file

@ -130,7 +130,7 @@ static QTimer* idleTimer = NULL;
const QString CHECK_VERSION_URL = "https://highfidelity.io/latestVersion.xml";
const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
const QString DEFAULT_SCRIPTS_JS_URL = "http://public.highfidelity.io/scripts/defaultScripts.js";
const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);

View file

@ -10,11 +10,14 @@
//
// Creates single flexible verlet-integrated strands that can be used for hair/fur/grass
#include "Hair.h"
#include <gpu/GPUConfig.h>
#include "Util.h"
#include "world.h"
#include "Hair.h"
const float HAIR_DAMPING = 0.99f;
const float CONSTRAINT_RELAXATION = 10.0f;
const float HAIR_ACCELERATION_COUPLING = 0.045f;

View file

@ -669,6 +669,49 @@ glm::vec3 Avatar::getDisplayNamePosition() {
return namePosition;
}
float Avatar::calculateDisplayNameScaleFactor(const glm::vec3& textPosition, bool inHMD) {
// We need to compute the scale factor such as the text remains with fixed size respect to window coordinates
// We project a unit vector and check the difference in screen coordinates, to check which is the
// correction scale needed
// save the matrices for later scale correction factor
// The up vector must be relative to the rotation current rotation matrix:
// we set the identity
glm::vec3 testPoint0 = textPosition;
glm::vec3 testPoint1 = textPosition + (Application::getInstance()->getCamera()->getRotation() * IDENTITY_UP);
double textWindowHeight;
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
float windowSizeX = glCanvas->getDeviceWidth();
float windowSizeY = glCanvas->getDeviceHeight();
glm::dmat4 modelViewMatrix;
glm::dmat4 projectionMatrix;
Application::getInstance()->getModelViewMatrix(&modelViewMatrix);
Application::getInstance()->getProjectionMatrix(&projectionMatrix);
glm::dvec4 p0 = modelViewMatrix * glm::dvec4(testPoint0, 1.0);
p0 = projectionMatrix * p0;
glm::dvec2 result0 = glm::vec2(windowSizeX * (p0.x / p0.w + 1.0f) * 0.5f, windowSizeY * (p0.y / p0.w + 1.0f) * 0.5f);
glm::dvec4 p1 = modelViewMatrix * glm::dvec4(testPoint1, 1.0);
p1 = projectionMatrix * p1;
glm::vec2 result1 = glm::vec2(windowSizeX * (p1.x / p1.w + 1.0f) * 0.5f, windowSizeY * (p1.y / p1.w + 1.0f) * 0.5f);
textWindowHeight = abs(result1.y - result0.y);
// need to scale to compensate for the font resolution due to the device
float scaleFactor = QApplication::desktop()->windowHandle()->devicePixelRatio() *
((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f);
if (inHMD) {
const float HMDMODE_NAME_SCALE = 0.65f;
scaleFactor *= HMDMODE_NAME_SCALE;
} else {
scaleFactor *= Application::getInstance()->getRenderResolutionScale();
}
return scaleFactor;
}
void Avatar::renderDisplayName() {
if (_displayName.isEmpty() || _displayNameAlpha == 0.0f) {
@ -700,78 +743,39 @@ void Avatar::renderDisplayName() {
frontAxis = glm::normalize(glm::vec3(frontAxis.z, 0.0f, -frontAxis.x));
float angle = acos(frontAxis.x) * ((frontAxis.z < 0) ? 1.0f : -1.0f);
glRotatef(glm::degrees(angle), 0.0f, 1.0f, 0.0f);
// We need to compute the scale factor such as the text remains with fixed size respect to window coordinates
// We project a unit vector and check the difference in screen coordinates, to check which is the
// correction scale needed
// save the matrices for later scale correction factor
glm::dmat4 modelViewMatrix;
glm::dmat4 projectionMatrix;
GLint viewportMatrix[4];
Application::getInstance()->getModelViewMatrix(&modelViewMatrix);
Application::getInstance()->getProjectionMatrix(&projectionMatrix);
glGetIntegerv(GL_VIEWPORT, viewportMatrix);
GLdouble result0[3], result1[3];
// The up vector must be relative to the rotation current rotation matrix:
// we set the identity
glm::dvec3 testPoint0 = glm::dvec3(textPosition);
glm::dvec3 testPoint1 = glm::dvec3(textPosition) + glm::dvec3(Application::getInstance()->getCamera()->getRotation() * IDENTITY_UP);
bool success;
success = gluProject(testPoint0.x, testPoint0.y, testPoint0.z,
(GLdouble*)&modelViewMatrix, (GLdouble*)&projectionMatrix, viewportMatrix,
&result0[0], &result0[1], &result0[2]);
success = success &&
gluProject(testPoint1.x, testPoint1.y, testPoint1.z,
(GLdouble*)&modelViewMatrix, (GLdouble*)&projectionMatrix, viewportMatrix,
&result1[0], &result1[1], &result1[2]);
float scaleFactor = calculateDisplayNameScaleFactor(textPosition, inHMD);
glScalef(scaleFactor, scaleFactor, 1.0);
glScalef(1.0f, -1.0f, 1.0f); // TextRenderer::draw paints the text upside down in y axis
if (success) {
double textWindowHeight = abs(result1[1] - result0[1]);
// need to scale to compensate for the font resolution due to the device
float scaleFactor = QApplication::desktop()->windowHandle()->devicePixelRatio() *
((textWindowHeight > EPSILON) ? 1.0f / textWindowHeight : 1.0f);
if (inHMD) {
const float HMDMODE_NAME_SCALE = 0.65f;
scaleFactor *= HMDMODE_NAME_SCALE;
} else {
scaleFactor *= Application::getInstance()->getRenderResolutionScale();
}
glScalef(scaleFactor, scaleFactor, 1.0);
glScalef(1.0f, -1.0f, 1.0f); // TextRenderer::draw paints the text upside down in y axis
int text_x = -_displayNameBoundingRect.width() / 2;
int text_y = -_displayNameBoundingRect.height() / 2;
int text_x = -_displayNameBoundingRect.width() / 2;
int text_y = -_displayNameBoundingRect.height() / 2;
// draw a gray background
int left = text_x + _displayNameBoundingRect.x();
int right = left + _displayNameBoundingRect.width();
int bottom = text_y + _displayNameBoundingRect.y();
int top = bottom + _displayNameBoundingRect.height();
const int border = 8;
bottom -= border;
left -= border;
top += border;
right += border;
// draw a gray background
int left = text_x + _displayNameBoundingRect.x();
int right = left + _displayNameBoundingRect.width();
int bottom = text_y + _displayNameBoundingRect.y();
int top = bottom + _displayNameBoundingRect.height();
const int border = 8;
bottom -= border;
left -= border;
top += border;
right += border;
// We are drawing coplanar textures with depth: need the polygon offset
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
// We are drawing coplanar textures with depth: need the polygon offset
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
glColor4f(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA);
renderBevelCornersRect(left, bottom, right - left, top - bottom, 3);
glColor4f(0.93f, 0.93f, 0.93f, _displayNameAlpha);
QByteArray ba = _displayName.toLocal8Bit();
const char* text = ba.data();
glDisable(GL_POLYGON_OFFSET_FILL);
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text);
}
glColor4f(0.2f, 0.2f, 0.2f, _displayNameAlpha * DISPLAYNAME_BACKGROUND_ALPHA / DISPLAYNAME_ALPHA);
renderBevelCornersRect(left, bottom, right - left, top - bottom, 3);
glColor4f(0.93f, 0.93f, 0.93f, _displayNameAlpha);
QByteArray ba = _displayName.toLocal8Bit();
const char* text = ba.data();
glDisable(GL_POLYGON_OFFSET_FILL);
textRenderer(DISPLAYNAME)->draw(text_x, text_y, text);
glPopMatrix();

View file

@ -230,6 +230,7 @@ protected:
float getPelvisFloatingHeight() const;
glm::vec3 getDisplayNamePosition();
float calculateDisplayNameScaleFactor(const glm::vec3& textPosition, bool inHMD);
void renderDisplayName();
virtual void renderBody(RenderMode renderMode, bool postLighting, float glowLevel = 0.0f);
virtual bool shouldRenderHead(const glm::vec3& cameraPosition, RenderMode renderMode) const;

View file

@ -582,7 +582,7 @@ void OculusManager::renderDistortionMesh(ovrPosef eyeRenderPose[ovrEye_Count]) {
glLoadIdentity();
GLCanvas::SharedPointer glCanvas = DependencyManager::get<GLCanvas>();
gluOrtho2D(0, glCanvas->getDeviceWidth(), 0, glCanvas->getDeviceHeight());
glOrtho(0, glCanvas->getDeviceWidth(), 0, glCanvas->getDeviceHeight(), -1.0, 1.0);
glDisable(GL_DEPTH_TEST);

View file

@ -180,7 +180,7 @@ void ApplicationOverlay::renderOverlay(bool renderToTexture) {
glPushMatrix(); {
glLoadIdentity();
gluOrtho2D(0, glCanvas->width(), glCanvas->height(), 0);
glOrtho(0, glCanvas->width(), glCanvas->height(), 0, -1.0, 1.0);
renderAudioMeter();
@ -224,7 +224,7 @@ void ApplicationOverlay::displayOverlayTexture() {
glMatrixMode(GL_PROJECTION);
glPushMatrix(); {
glLoadIdentity();
gluOrtho2D(0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight(), 0);
glOrtho(0, glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight(), 0, -1.0, 1.0);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);

View file

@ -128,7 +128,7 @@ void RearMirrorTools::displayIcon(QRect bounds, QRect iconBounds, GLuint texture
glPushMatrix();
glLoadIdentity();
gluOrtho2D(bounds.left(), bounds.right(), bounds.bottom(), bounds.top());
glOrtho(bounds.left(), bounds.right(), bounds.bottom(), bounds.top(), -1.0, 1.0);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);

View file

@ -100,26 +100,31 @@ void ImageOverlay::render(RenderArgs* args) {
float w = fromImage.width() / imageWidth; // ?? is this what we want? not sure
float h = fromImage.height() / imageHeight;
int left = _bounds.left();
int right = _bounds.right() + 1;
int top = _bounds.top();
int bottom = _bounds.bottom() + 1;
glBegin(GL_QUADS);
if (_renderImage) {
glTexCoord2f(x, 1.0f - y);
}
glVertex2f(_bounds.left(), _bounds.top());
glVertex2f(left, top);
if (_renderImage) {
glTexCoord2f(x + w, 1.0f - y);
}
glVertex2f(_bounds.right(), _bounds.top());
glVertex2f(right, top);
if (_renderImage) {
glTexCoord2f(x + w, 1.0f - (y + h));
}
glVertex2f(_bounds.right(), _bounds.bottom());
glVertex2f(right, bottom);
if (_renderImage) {
glTexCoord2f(x, 1.0f - (y + h));
}
glVertex2f(_bounds.left(), _bounds.bottom());
glVertex2f(left, bottom);
glEnd();
if (_renderImage) {

View file

@ -70,11 +70,16 @@ void TextOverlay::render(RenderArgs* args) {
glColor4f(backgroundColor.red / MAX_COLOR, backgroundColor.green / MAX_COLOR, backgroundColor.blue / MAX_COLOR,
getBackgroundAlpha());
int left = _bounds.left();
int right = _bounds.right() + 1;
int top = _bounds.top();
int bottom = _bounds.bottom() + 1;
glBegin(GL_QUADS);
glVertex2f(_bounds.left(), _bounds.top());
glVertex2f(_bounds.right(), _bounds.top());
glVertex2f(_bounds.right(), _bounds.bottom());
glVertex2f(_bounds.left(), _bounds.bottom());
glVertex2f(left, top);
glVertex2f(right, top);
glVertex2f(right, bottom);
glVertex2f(left, bottom);
glEnd();
// Same font properties as textSize()

View file

@ -5,5 +5,5 @@ setup_hifi_library(Network Script)
link_hifi_libraries(shared gpu model fbx)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -7,5 +7,5 @@ include_glm()
link_hifi_libraries(networking shared)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -5,8 +5,7 @@ setup_hifi_library(Network Script)
include_glm()
link_hifi_libraries(shared octree voxels gpu model fbx networking physics)
include_hifi_library_headers(gpu model fbx)
link_hifi_libraries(audio shared octree voxels networking physics gpu model fbx)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -3,5 +3,5 @@ set(TARGET_NAME embedded-webserver)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
setup_hifi_library(Network)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -5,7 +5,7 @@ setup_hifi_library(Widgets OpenGL Network Script)
include_glm()
link_hifi_libraries(shared gpu script-engine)
link_hifi_libraries(shared gpu script-engine render-utils)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -62,6 +62,7 @@ EntityTreeRenderer::~EntityTreeRenderer() {
}
void EntityTreeRenderer::clear() {
leaveAllEntities();
foreach (const EntityItemID& entityID, _entityScripts.keys()) {
checkAndCallUnload(entityID);
}
@ -82,8 +83,7 @@ void EntityTreeRenderer::init() {
// make sure our "last avatar position" is something other than our current position, so that on our
// first chance, we'll check for enter/leave entity events.
glm::vec3 avatarPosition = _viewState->getAvatarPosition();
_lastAvatarPosition = avatarPosition + glm::vec3(1.0f, 1.0f, 1.0f);
_lastAvatarPosition = _viewState->getAvatarPosition() + glm::vec3(1.0f, 1.0f, 1.0f);
connect(entityTree, &EntityTree::deletingEntity, this, &EntityTreeRenderer::deletingEntity);
connect(entityTree, &EntityTree::addingEntity, this, &EntityTreeRenderer::checkAndCallPreload);
@ -97,13 +97,15 @@ QScriptValue EntityTreeRenderer::loadEntityScript(const EntityItemID& entityItem
}
QString EntityTreeRenderer::loadScriptContents(const QString& scriptMaybeURLorText) {
QString EntityTreeRenderer::loadScriptContents(const QString& scriptMaybeURLorText, bool& isURL) {
QUrl url(scriptMaybeURLorText);
// If the url is not valid, this must be script text...
if (!url.isValid()) {
isURL = false;
return scriptMaybeURLorText;
}
isURL = true;
QString scriptContents; // assume empty
@ -173,7 +175,8 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity) {
return QScriptValue(); // no script
}
QString scriptContents = loadScriptContents(entityScript);
bool isURL = false; // loadScriptContents() will tell us if this is a URL or just text.
QString scriptContents = loadScriptContents(entityScript, isURL);
QScriptSyntaxCheckResult syntaxCheck = QScriptEngine::checkSyntax(scriptContents);
if (syntaxCheck.state() != QScriptSyntaxCheckResult::Valid) {
@ -184,6 +187,9 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity) {
return QScriptValue(); // invalid script
}
if (isURL) {
_entitiesScriptEngine->setParentURL(entity->getScript());
}
QScriptValue entityScriptConstructor = _entitiesScriptEngine->evaluate(scriptContents);
if (!entityScriptConstructor.isFunction()) {
@ -197,6 +203,10 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity) {
EntityScriptDetails newDetails = { entityScript, entityScriptObject };
_entityScripts[entityID] = newDetails;
if (isURL) {
_entitiesScriptEngine->setParentURL("");
}
return entityScriptObject; // newly constructed
}
@ -287,6 +297,27 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
}
}
void EntityTreeRenderer::leaveAllEntities() {
if (_tree) {
_tree->lockForWrite(); // so that our scripts can do edits if they want
// for all of our previous containing entities, if they are no longer containing then send them a leave event
foreach(const EntityItemID& entityID, _currentEntitiesInside) {
emit leaveEntity(entityID);
QScriptValueList entityArgs = createEntityArgs(entityID);
QScriptValue entityScript = loadEntityScript(entityID);
if (entityScript.property("leaveEntity").isValid()) {
entityScript.property("leaveEntity").call(entityScript, entityArgs);
}
}
_currentEntitiesInside.clear();
// make sure our "last avatar position" is something other than our current position, so that on our
// first chance, we'll check for enter/leave entity events.
_lastAvatarPosition = _viewState->getAvatarPosition() + glm::vec3(1.0f, 1.0f, 1.0f);
_tree->unlock();
}
}
void EntityTreeRenderer::render(RenderArgs::RenderMode renderMode, RenderArgs::RenderSide renderSide) {
if (_tree) {
Model::startScene(renderSide);

View file

@ -129,6 +129,7 @@ private:
QScriptValueList createEntityArgs(const EntityItemID& entityID);
void checkEnterLeaveEntities();
void leaveAllEntities();
glm::vec3 _lastAvatarPosition;
QVector<EntityItemID> _currentEntitiesInside;
@ -138,7 +139,7 @@ private:
QScriptValue loadEntityScript(EntityItem* entity);
QScriptValue loadEntityScript(const EntityItemID& entityItemID);
QScriptValue getPreviouslyLoadedEntityScript(const EntityItemID& entityItemID);
QString loadScriptContents(const QString& scriptMaybeURLorText);
QString loadScriptContents(const QString& scriptMaybeURLorText, bool& isURL);
QScriptValueList createMouseEventArgs(const EntityItemID& entityID, QMouseEvent* event, unsigned int deviceID);
QScriptValueList createMouseEventArgs(const EntityItemID& entityID, const MouseEvent& mouseEvent);

View file

@ -5,7 +5,7 @@ setup_hifi_library(Network Script)
include_glm()
link_hifi_libraries(shared octree gpu model fbx networking animation physics)
link_hifi_libraries(avatars shared octree gpu model fbx networking animation physics)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -11,5 +11,5 @@ find_package(ZLIB REQUIRED)
include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -19,7 +19,7 @@ elseif (WIN32)
# we're using static GLEW, so define GLEW_STATIC
add_definitions(-DGLEW_STATIC)
target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" opengl32.lib)
target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} opengl32.lib)
# need to bubble up the GLEW_INCLUDE_DIRS
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${GLEW_INCLUDE_DIRS}")
@ -44,5 +44,5 @@ else ()
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${OPENGL_INCLUDE_DIR}")
endif (APPLE)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -10,5 +10,5 @@ link_hifi_libraries(shared networking)
include_glm()
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -8,4 +8,4 @@ include_glm()
link_hifi_libraries(shared gpu)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
include_dependency_includes()

View file

@ -28,5 +28,5 @@ target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES} ${TBB_LIBRARIES})
# append libcuckoo includes to our list of includes to bubble
list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${TBB_INCLUDE_DIRS}")
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -15,5 +15,5 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
# append ZLIB and OpenSSL to our list of libraries to link
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -15,5 +15,5 @@ link_hifi_libraries(shared)
## append BULLET to our list of libraries to link
#list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${BULLET_LIBRARIES}")
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -5,12 +5,7 @@ setup_hifi_library(Widgets OpenGL Network Script)
include_glm()
link_hifi_libraries(shared gpu)
link_hifi_libraries(animation fbx shared gpu)
if (WIN32)
find_package(GLUT REQUIRED)
include_directories(SYSTEM "${GLUT_INCLUDE_DIRS}")
endif ()
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -5,7 +5,7 @@ setup_hifi_library(Gui Network Script Widgets)
include_glm()
link_hifi_libraries(shared octree voxels gpu model fbx entities animation audio physics)
link_hifi_libraries(shared octree voxels gpu model fbx entities animation audio physics metavoxels)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
gpu model ()

View file

@ -601,16 +601,20 @@ void ScriptEngine::stopTimer(QTimer *timer) {
}
QUrl ScriptEngine::resolvePath(const QString& include) const {
// first lets check to see if it's already a full URL
QUrl url(include);
// first lets check to see if it's already a full URL
if (!url.scheme().isEmpty()) {
return url;
}
// we apparently weren't a fully qualified url, so, let's assume we're relative
// to the original URL of our script
QUrl parentURL(_fileNameString);
QUrl parentURL;
if (_parentURL.isEmpty()) {
parentURL = QUrl(_fileNameString);
} else {
parentURL = QUrl(_parentURL);
}
// if the parent URL's scheme is empty, then this is probably a local file...
if (parentURL.scheme().isEmpty()) {
parentURL = QUrl::fromLocalFile(_fileNameString);
@ -643,6 +647,7 @@ void ScriptEngine::include(const QString& includeFile) {
#else
QString fileName = url.toLocalFile();
#endif
QFile scriptFile(fileName);
if (scriptFile.open(QFile::ReadOnly | QFile::Text)) {
qDebug() << "Including file:" << fileName;

View file

@ -89,6 +89,8 @@ public:
void setUserLoaded(bool isUserLoaded) { _isUserLoaded = isUserLoaded; }
bool isUserLoaded() const { return _isUserLoaded; }
void setParentURL(const QString& parentURL) { _parentURL = parentURL; }
public slots:
void loadURL(const QUrl& scriptURL);
void stop();
@ -120,6 +122,7 @@ signals:
protected:
QString _scriptContents;
QString _parentURL;
bool _isFinished;
bool _isRunning;
bool _isInitialized;

View file

@ -1,7 +1,8 @@
set(TARGET_NAME shared)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
setup_hifi_library(Network Widgets)
# TODO: there isn't really a good reason to have Script linked here - let's get what is requiring it out (RegisteredMetaTypes.cpp)
setup_hifi_library(Network Script Widgets)
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -98,6 +98,14 @@ std::ostream& operator<<(std::ostream& s, const CapsuleShape& capsule) {
#ifndef QT_NO_DEBUG_STREAM
#include <QDebug>
QDebug& operator<<(QDebug& dbg, const glm::vec2& v) {
dbg.nospace() << "{type='glm::vec2'"
", x=" << v.x <<
", y=" << v.y <<
"}";
return dbg;
}
QDebug& operator<<(QDebug& dbg, const glm::vec3& v) {
dbg.nospace() << "{type='glm::vec3'"
", x=" << v.x <<

View file

@ -49,6 +49,7 @@ std::ostream& operator<<(std::ostream& s, const CapsuleShape& capsule);
#ifndef QT_NO_DEBUG_STREAM
class QDebug;
// Add support for writing these to qDebug().
QDebug& operator<<(QDebug& s, const glm::vec2& v);
QDebug& operator<<(QDebug& s, const glm::vec3& v);
QDebug& operator<<(QDebug& s, const glm::quat& q);
QDebug& operator<<(QDebug& s, const glm::mat4& m);

View file

@ -14,5 +14,5 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}")
# add it to our list of libraries to link
target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
# call macro to link our dependencies and bubble them up via a property on our target
link_shared_dependencies()
# call macro to include our dependency includes and bubble them up via a property on our target
include_dependency_includes()

View file

@ -7,4 +7,4 @@ include_glm()
# link in the shared libraries
link_hifi_libraries(shared audio networking)
link_shared_dependencies()
include_dependency_includes()

View file

@ -5,4 +5,4 @@ setup_hifi_project()
# link in the shared libraries
link_hifi_libraries(shared networking)
link_shared_dependencies()
include_dependency_includes()

View file

@ -9,4 +9,4 @@ setup_hifi_project(Network Script Widgets)
# link in the shared libraries
link_hifi_libraries(metavoxels networking shared)
link_shared_dependencies()
include_dependency_includes()

View file

@ -5,4 +5,4 @@ setup_hifi_project()
# link in the shared libraries
link_hifi_libraries(shared networking)
link_shared_dependencies()
include_dependency_includes()

View file

@ -7,4 +7,4 @@ include_glm()
# link in the shared libraries
link_hifi_libraries(shared octree voxels gpu model fbx metavoxels networking entities avatars audio animation script-engine physics)
link_shared_dependencies()
include_dependency_includes()

View file

@ -7,4 +7,4 @@ include_glm()
# link in the shared libraries
link_hifi_libraries(shared physics)
link_shared_dependencies()
include_dependency_includes()

View file

@ -7,4 +7,4 @@ include_glm()
# link in the shared libraries
link_hifi_libraries(shared)
link_shared_dependencies()
include_dependency_includes()

View file

@ -5,4 +5,4 @@ include_glm()
link_hifi_libraries(metavoxels)
link_shared_dependencies()
include_dependency_includes()

View file

@ -5,4 +5,4 @@ include_glm()
link_hifi_libraries(metavoxels)
link_shared_dependencies()
include_dependency_includes()

View file

@ -1,4 +1,4 @@
set(TARGET_NAME mtc)
setup_hifi_project()
link_shared_dependencies()
include_dependency_includes()