mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 06:32:35 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into flocking_birds
Conflicts: examples/bot.js
This commit is contained in:
commit
15b5bb4385
41 changed files with 766 additions and 207 deletions
|
@ -8,15 +8,11 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
|||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/")
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5Script REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Network Script Widgets)
|
||||
|
||||
include("${MACRO_DIR}/SetupHifiProject.cmake")
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Network Script Widgets)
|
||||
|
||||
# include glm
|
||||
include("${MACRO_DIR}/IncludeGLM.cmake")
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
@ -40,3 +36,5 @@ endif (UNIX)
|
|||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script)
|
||||
|
|
|
@ -18,8 +18,6 @@ include(${MACRO_DIR}/SetupHifiProject.cmake)
|
|||
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Network)
|
||||
|
||||
# remove and then copy the files for the webserver
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove_directory
|
||||
|
@ -36,4 +34,6 @@ link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}")
|
|||
|
||||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network)
|
|
@ -18,6 +18,10 @@ function getRandomInt (min, max) {
|
|||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
function printVector(string, vector) {
|
||||
print(string + " " + vector.x + ", " + vector.y + ", " + vector.z);
|
||||
}
|
||||
|
||||
var CHANCE_OF_MOVING = 0.005;
|
||||
var CHANCE_OF_SOUND = 0.005;
|
||||
var CHANCE_OF_HEAD_TURNING = 0.05;
|
||||
|
@ -31,6 +35,7 @@ var X_MIN = 0.0;
|
|||
var X_MAX = 5.0;
|
||||
var Z_MIN = 0.0;
|
||||
var Z_MAX = 5.0;
|
||||
var Y_PELVIS = 2.5;
|
||||
|
||||
var MOVE_RANGE_SMALL = 0.5;
|
||||
var MOVE_RANGE_BIG = Math.max(X_MAX - X_MIN, Z_MAX - Z_MIN) / 2.0;
|
||||
|
@ -41,7 +46,7 @@ var TURN_RATE = 0.15;
|
|||
var PITCH_RATE = 0.20;
|
||||
var PITCH_RANGE = 30.0;
|
||||
|
||||
var firstPosition = { x: getRandomFloat(X_MIN, X_MAX), y: 0, z: getRandomFloat(Z_MIN, Z_MAX) };
|
||||
var firstPosition = { x: getRandomFloat(X_MIN, X_MAX), y: Y_PELVIS, z: getRandomFloat(Z_MIN, Z_MAX) };
|
||||
var targetPosition = { x: 0, y: 0, z: 0 };
|
||||
var targetDirection = { x: 0, y: 0, z: 0, w: 0 };
|
||||
var currentDirection = { x: 0, y: 0, z: 0, w: 0 };
|
||||
|
@ -72,9 +77,6 @@ function playRandomSound(position) {
|
|||
}
|
||||
}
|
||||
|
||||
// change the avatar's position to the random one
|
||||
Avatar.position = firstPosition;
|
||||
|
||||
// pick an integer between 1 and 20 for the face model for this bot
|
||||
botNumber = getRandomInt(1, 100);
|
||||
|
||||
|
@ -103,6 +105,10 @@ Avatar.billboardURL = "https://s3-us-west-1.amazonaws.com/highfidelity-public/me
|
|||
|
||||
Agent.isAvatar = true;
|
||||
|
||||
// change the avatar's position to the random one
|
||||
Avatar.position = firstPosition;
|
||||
printVector("New bot, position = ", Avatar.position);
|
||||
|
||||
function updateBehavior(deltaTime) {
|
||||
if (Math.random() < CHANCE_OF_SOUND) {
|
||||
playRandomSound(Avatar.position);
|
||||
|
@ -132,6 +138,7 @@ function updateBehavior(deltaTime) {
|
|||
}
|
||||
targetPosition.x = clamp(targetPosition.x, X_MIN, X_MAX);
|
||||
targetPosition.z = clamp(targetPosition.z, Z_MIN, Z_MAX);
|
||||
targetPosition.y = Y_PELVIS;
|
||||
|
||||
isMoving = true;
|
||||
} else {
|
||||
|
|
|
@ -57,12 +57,12 @@ function shootBullet(position, velocity) {
|
|||
damping: 0 });
|
||||
|
||||
// Play firing sounds
|
||||
audioOptions.position = position;
|
||||
audioOptions.position = position;
|
||||
Audio.playSound(fireSound, audioOptions);
|
||||
}
|
||||
|
||||
function particleCollisionWithVoxel(particle, voxel) {
|
||||
var HOLE_SIZE = 0.25;
|
||||
var HOLE_SIZE = 0.125;
|
||||
var particleProperties = Particles.getParticleProperties(particle);
|
||||
var position = particleProperties.position;
|
||||
Particles.deleteParticle(particle);
|
||||
|
|
54
examples/localVoxelsExample.js
Normal file
54
examples/localVoxelsExample.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
var TREE_SCALE = 16384;
|
||||
var tree = LocalVoxels("tree");
|
||||
tree.setVoxel(0, 0, 0,
|
||||
0.5 * TREE_SCALE,
|
||||
255, 0, 0);
|
||||
tree.setVoxel(0.5 * TREE_SCALE,
|
||||
0.5 * TREE_SCALE,
|
||||
0.5 * TREE_SCALE,
|
||||
0.5 * TREE_SCALE,
|
||||
0, 255, 0);
|
||||
|
||||
var copy = LocalVoxels("copy");
|
||||
tree.pasteFrom(0, 0, 0, TREE_SCALE, "copy");
|
||||
tree.pasteFrom(0, 0, 0, TREE_SCALE, "clipboard");
|
||||
|
||||
var overlay1 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 1, z: 1},
|
||||
size: 1,
|
||||
name: "tree"
|
||||
});
|
||||
var overlay2 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 2, z: 1},
|
||||
size: 1,
|
||||
name: "tree"
|
||||
});
|
||||
var overlay3 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 3, z: 1},
|
||||
size: 1,
|
||||
name: "tree"
|
||||
});
|
||||
var overlay4 = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 4, z: 1},
|
||||
size: 1,
|
||||
name: "copy"
|
||||
});
|
||||
|
||||
var clipboard = Overlays.addOverlay("localvoxels", {
|
||||
position: {x: 1, y: 5, z: 1},
|
||||
size: 1,
|
||||
name: "clipboard"
|
||||
});
|
||||
|
||||
|
||||
|
||||
// When our script shuts down, we should clean up all of our overlays
|
||||
function scriptEnding() {
|
||||
Overlays.deleteOverlay(overlay1);
|
||||
Overlays.deleteOverlay(overlay2);
|
||||
Overlays.deleteOverlay(overlay3);
|
||||
Overlays.deleteOverlay(overlay4);
|
||||
Overlays.deleteOverlay(clipboard);
|
||||
}
|
||||
Script.scriptEnding.connect(scriptEnding);
|
|
@ -75,15 +75,7 @@ foreach(EXTERNAL_SOURCE_SUBDIR ${EXTERNAL_SOURCE_SUBDIRS})
|
|||
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}")
|
||||
endforeach(EXTERNAL_SOURCE_SUBDIR)
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Gui REQUIRED)
|
||||
find_package(Qt5Multimedia REQUIRED)
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5OpenGL REQUIRED)
|
||||
find_package(Qt5Svg REQUIRED)
|
||||
find_package(Qt5WebKit REQUIRED)
|
||||
find_package(Qt5WebKitWidgets REQUIRED)
|
||||
find_package(Qt5Xml REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools)
|
||||
|
||||
# grab the ui files in resources/ui
|
||||
file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
|
||||
|
@ -180,8 +172,6 @@ if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
|
|||
target_link_libraries(${TARGET_NAME} "${LIBOVR_LIBRARIES}")
|
||||
endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR)
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools)
|
||||
|
||||
# include headers for interface and InterfaceConfig.
|
||||
include_directories(
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
|
@ -200,6 +190,8 @@ target_link_libraries(
|
|||
${TARGET_NAME}
|
||||
"${FACESHIFT_LIBRARIES}"
|
||||
"${ZLIB_LIBRARIES}"
|
||||
Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL
|
||||
Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include <ResourceCache.h>
|
||||
#include <UUID.h>
|
||||
#include <VoxelSceneStats.h>
|
||||
#include <LocalVoxelsList.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "ClipboardScriptingInterface.h"
|
||||
|
@ -311,7 +312,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
checkVersion();
|
||||
|
||||
_overlays.init(_glWidget); // do this before scripts load
|
||||
|
||||
|
||||
LocalVoxelsList::getInstance()->addPersistantTree(DOMAIN_TREE_NAME, _voxels.getTree());
|
||||
LocalVoxelsList::getInstance()->addPersistantTree(CLIPBOARD_TREE_NAME, &_clipboard);
|
||||
|
||||
// do this as late as possible so that all required subsystems are inialized
|
||||
loadScripts();
|
||||
}
|
||||
|
@ -398,6 +402,12 @@ void Application::initializeGL() {
|
|||
|
||||
// initialize glut for shape drawing; Qt apparently initializes it on OS X
|
||||
#ifndef __APPLE__
|
||||
static bool isInitialized = false;
|
||||
if (isInitialized) {
|
||||
return;
|
||||
} else {
|
||||
isInitialized = true;
|
||||
}
|
||||
int argc = 0;
|
||||
glutInit(&argc, 0);
|
||||
#endif
|
||||
|
@ -1424,6 +1434,7 @@ void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestinati
|
|||
args.newBaseOctCode = octalCodeDestination;
|
||||
_sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args);
|
||||
|
||||
// Switch back to clipboard if it was an import
|
||||
if (_sharedVoxelSystem.getTree() != &_clipboard) {
|
||||
_sharedVoxelSystem.killLocalVoxels();
|
||||
_sharedVoxelSystem.changeTree(&_clipboard);
|
||||
|
@ -1885,6 +1896,8 @@ void Application::update(float deltaTime) {
|
|||
_particles.update(); // update the particles...
|
||||
_particleCollisionSystem.update(); // collide the particles...
|
||||
|
||||
_overlays.update(deltaTime);
|
||||
|
||||
// let external parties know we're updating
|
||||
emit simulating(deltaTime);
|
||||
}
|
||||
|
@ -3466,7 +3479,6 @@ void Application::cleanupScriptMenuItem(const QString& scriptMenuName) {
|
|||
}
|
||||
|
||||
void Application::loadScript(const QString& fileNameString) {
|
||||
_activeScripts.append(fileNameString);
|
||||
QByteArray fileNameAscii = fileNameString.toLocal8Bit();
|
||||
const char* fileName = fileNameAscii.data();
|
||||
|
||||
|
@ -3476,6 +3488,7 @@ void Application::loadScript(const QString& fileNameString) {
|
|||
return;
|
||||
}
|
||||
qDebug("Loading file %s...", fileName);
|
||||
_activeScripts.append(fileNameString);
|
||||
|
||||
// get file length....
|
||||
unsigned long fileLength = file.tellg();
|
||||
|
|
|
@ -90,5 +90,4 @@ void ClipboardScriptingInterface::nudgeVoxel(float x, float y, float z, float s,
|
|||
s / (float)TREE_SCALE };
|
||||
|
||||
Application::getInstance()->nudgeVoxelsByVector(sourceVoxel, nudgeVecInTreeSpace);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <VoxelImporter.h>
|
||||
#include <Application.h>
|
||||
#include <LocalVoxelsList.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QThreadPool>
|
||||
|
@ -31,6 +32,8 @@ VoxelImporter::VoxelImporter(QWidget* parent) :
|
|||
_task(NULL),
|
||||
_didImport(false)
|
||||
{
|
||||
LocalVoxelsList::getInstance()->addPersistantTree(IMPORT_TREE_NAME, &_voxelTree);
|
||||
|
||||
connect(&_voxelTree, SIGNAL(importProgress(int)), &_importDialog, SLOT(setProgressBarValue(int)));
|
||||
connect(&_importDialog, SIGNAL(canceled()), this, SLOT(cancel()));
|
||||
connect(&_importDialog, SIGNAL(accepted()), this, SLOT(import()));
|
||||
|
|
|
@ -53,7 +53,7 @@ GLubyte identityIndicesRight[] = { 1, 2, 6, 1, 6, 5 };
|
|||
GLubyte identityIndicesFront[] = { 0, 2, 1, 0, 3, 2 };
|
||||
GLubyte identityIndicesBack[] = { 4, 5, 6, 4, 6, 7 };
|
||||
|
||||
VoxelSystem::VoxelSystem(float treeScale, int maxVoxels)
|
||||
VoxelSystem::VoxelSystem(float treeScale, int maxVoxels, VoxelTree* tree)
|
||||
: NodeData(),
|
||||
_treeScale(treeScale),
|
||||
_maxVoxels(maxVoxels),
|
||||
|
@ -69,7 +69,7 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels)
|
|||
_voxelsInReadArrays = _voxelsInWriteArrays = _voxelsUpdated = 0;
|
||||
_writeRenderFullVBO = true;
|
||||
_readRenderFullVBO = true;
|
||||
_tree = new VoxelTree();
|
||||
_tree = (tree) ? tree : new VoxelTree();
|
||||
|
||||
_tree->getRoot()->setVoxelSystem(this);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class VoxelSystem : public NodeData, public OctreeElementDeleteHook, public Octr
|
|||
friend class VoxelHideShowThread;
|
||||
|
||||
public:
|
||||
VoxelSystem(float treeScale = TREE_SCALE, int maxVoxels = DEFAULT_MAX_VOXELS_PER_SYSTEM);
|
||||
VoxelSystem(float treeScale = TREE_SCALE, int maxVoxels = DEFAULT_MAX_VOXELS_PER_SYSTEM, VoxelTree* tree = NULL);
|
||||
~VoxelSystem();
|
||||
|
||||
void setDataSourceUUID(const QUuid& dataSourceUUID) { _dataSourceUUID = dataSourceUUID; }
|
||||
|
@ -52,8 +52,8 @@ public:
|
|||
|
||||
int parseData(const QByteArray& packet);
|
||||
|
||||
bool isInitialized() { return _initialized; }
|
||||
virtual void init();
|
||||
void simulate(float deltaTime) { }
|
||||
void render();
|
||||
|
||||
void changeTree(VoxelTree* newTree);
|
||||
|
|
|
@ -41,15 +41,12 @@ TextureCache::~TextureCache() {
|
|||
glDeleteTextures(1, &id);
|
||||
}
|
||||
if (_primaryFramebufferObject) {
|
||||
delete _primaryFramebufferObject;
|
||||
glDeleteTextures(1, &_primaryDepthTextureID);
|
||||
}
|
||||
if (_secondaryFramebufferObject) {
|
||||
delete _secondaryFramebufferObject;
|
||||
}
|
||||
if (_tertiaryFramebufferObject) {
|
||||
delete _tertiaryFramebufferObject;
|
||||
}
|
||||
|
||||
delete _primaryFramebufferObject;
|
||||
delete _secondaryFramebufferObject;
|
||||
delete _tertiaryFramebufferObject;
|
||||
}
|
||||
|
||||
GLuint TextureCache::getPermutationNormalTextureID() {
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
//
|
||||
// ClipboardOverlay.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/20/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QGLWidget>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "ClipboardOverlay.h"
|
||||
#include "../Application.h"
|
||||
|
||||
static int lastVoxelCount = 0;
|
||||
|
||||
ClipboardOverlay::ClipboardOverlay() {
|
||||
}
|
||||
|
||||
ClipboardOverlay::~ClipboardOverlay() {
|
||||
}
|
||||
|
||||
void ClipboardOverlay::render() {
|
||||
if (!_visible) {
|
||||
return; // do nothing if we're not visible
|
||||
}
|
||||
|
||||
VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem();
|
||||
VoxelTree* clipboard = Application::getInstance()->getClipboard();
|
||||
if (voxelSystem->getTree() != clipboard) {
|
||||
voxelSystem->changeTree(clipboard);
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
glScalef(_size, _size, _size);
|
||||
|
||||
// We only force the redraw when the clipboard content has changed
|
||||
if (lastVoxelCount != clipboard->getOctreeElementsCount()) {
|
||||
voxelSystem->forceRedrawEntireTree();
|
||||
lastVoxelCount = clipboard->getOctreeElementsCount();
|
||||
}
|
||||
|
||||
voxelSystem->render();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
//
|
||||
// ClipboardOverlay.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/20/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __interface__ClipboardOverlay__
|
||||
#define __interface__ClipboardOverlay__
|
||||
|
||||
#include "Volume3DOverlay.h"
|
||||
|
||||
class ClipboardOverlay : public Volume3DOverlay {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ClipboardOverlay();
|
||||
~ClipboardOverlay();
|
||||
|
||||
virtual void render();
|
||||
};
|
||||
|
||||
|
||||
#endif /* defined(__interface__ClipboardOverlay__) */
|
84
interface/src/ui/LocalVoxelsOverlay.cpp
Normal file
84
interface/src/ui/LocalVoxelsOverlay.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
//
|
||||
// LocalVoxelsOverlay.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/28/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
//
|
||||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QGLWidget>
|
||||
#include <QScriptValue>
|
||||
|
||||
#include <VoxelSystem.h>
|
||||
#include <Application.h>
|
||||
|
||||
#include "LocalVoxelsOverlay.h"
|
||||
|
||||
QMap<QString, WeakVoxelSystemPointer> LocalVoxelsOverlay::_voxelSystemMap;
|
||||
|
||||
LocalVoxelsOverlay::LocalVoxelsOverlay() :
|
||||
Volume3DOverlay(),
|
||||
_voxelCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
LocalVoxelsOverlay::~LocalVoxelsOverlay() {
|
||||
_voxelSystem->changeTree(new VoxelTree());
|
||||
_voxelSystem.clear();
|
||||
if (_voxelSystemMap.value(_treeName).isNull()) {
|
||||
_voxelSystemMap.remove(_treeName);
|
||||
}
|
||||
_tree.clear();
|
||||
LocalVoxelsList::getInstance()->remove(_treeName);
|
||||
}
|
||||
|
||||
void LocalVoxelsOverlay::update(float deltatime) {
|
||||
if (!_voxelSystem->isInitialized()) {
|
||||
_voxelSystem->init();
|
||||
}
|
||||
|
||||
if (_voxelCount != _tree->getOctreeElementsCount()) {
|
||||
_voxelCount = _tree->getOctreeElementsCount();
|
||||
_voxelSystem->forceRedrawEntireTree();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalVoxelsOverlay::render() {
|
||||
if (_visible && _size > 0 && _voxelSystem && _voxelSystem->isInitialized()) {
|
||||
glPushMatrix(); {
|
||||
glTranslatef(_position.x, _position.y, _position.z);
|
||||
glScalef(_size, _size, _size);
|
||||
_voxelSystem->render();
|
||||
} glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalVoxelsOverlay::setProperties(const QScriptValue &properties) {
|
||||
Volume3DOverlay::setProperties(properties);
|
||||
|
||||
QScriptValue treeName = properties.property("name");
|
||||
// if "end" property was not there, check to see if they included aliases: endPoint, or p2
|
||||
if (treeName.isValid()) {
|
||||
if ((_treeName = treeName.toString()) == DOMAIN_TREE_NAME) {
|
||||
qDebug() << "addOverlay(): Can't create overlay from domain tree";
|
||||
return;
|
||||
}
|
||||
_tree = LocalVoxelsList::getInstance()->getTree(_treeName);
|
||||
if (_tree.isNull()) {
|
||||
qDebug() << "addOverlay(): Invalid tree name";
|
||||
return;
|
||||
}
|
||||
|
||||
_voxelSystem = _voxelSystemMap[_treeName];
|
||||
if (_voxelSystem.isNull()) {
|
||||
_voxelSystem = StrongVoxelSystemPointer(new VoxelSystem(1,
|
||||
DEFAULT_MAX_VOXELS_PER_SYSTEM,
|
||||
_tree.data()));
|
||||
_voxelSystemMap.insert(_treeName, _voxelSystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
interface/src/ui/LocalVoxelsOverlay.h
Normal file
50
interface/src/ui/LocalVoxelsOverlay.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
//
|
||||
// LocalVoxelsOverlay.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/28/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
// Scriptable interface for LocalVoxels
|
||||
//
|
||||
|
||||
#ifndef __hifi__LocalVoxelsOverlay__
|
||||
#define __hifi__LocalVoxelsOverlay__
|
||||
|
||||
// include this before QGLWidget, which includes an earlier version of OpenGL
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include <QGLWidget>
|
||||
#include <QScriptValue>
|
||||
#include <QMap>
|
||||
#include <QSharedPointer>
|
||||
#include <QWeakPointer>
|
||||
|
||||
#include <LocalVoxelsList.h>
|
||||
|
||||
#include "Volume3DOverlay.h"
|
||||
|
||||
typedef QSharedPointer<VoxelSystem> StrongVoxelSystemPointer;
|
||||
typedef QWeakPointer<VoxelSystem> WeakVoxelSystemPointer;
|
||||
|
||||
class LocalVoxelsOverlay : public Volume3DOverlay {
|
||||
Q_OBJECT
|
||||
public:
|
||||
LocalVoxelsOverlay();
|
||||
~LocalVoxelsOverlay();
|
||||
|
||||
virtual void update(float deltatime);
|
||||
virtual void render();
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
|
||||
private:
|
||||
static QMap<QString, WeakVoxelSystemPointer> _voxelSystemMap; // treeName/voxelSystem
|
||||
|
||||
QString _treeName;
|
||||
StrongVoxelTreePointer _tree; // so that the tree doesn't get freed
|
||||
int _voxelCount;
|
||||
StrongVoxelSystemPointer _voxelSystem;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__LocalVoxelsOverlay__) */
|
|
@ -28,6 +28,7 @@ public:
|
|||
Overlay();
|
||||
~Overlay();
|
||||
void init(QGLWidget* parent);
|
||||
virtual void update(float deltatime) {}
|
||||
virtual void render() = 0;
|
||||
|
||||
// getters
|
||||
|
|
|
@ -12,20 +12,41 @@
|
|||
#include "Overlays.h"
|
||||
#include "Sphere3DOverlay.h"
|
||||
#include "TextOverlay.h"
|
||||
#include "ClipboardOverlay.h"
|
||||
#include "LocalVoxelsOverlay.h"
|
||||
|
||||
unsigned int Overlays::_nextOverlayID = 1;
|
||||
|
||||
Overlays::Overlays() {
|
||||
Overlays::Overlays() : _nextOverlayID(1) {
|
||||
}
|
||||
|
||||
Overlays::~Overlays() {
|
||||
QMap<unsigned int, Overlay*>::iterator it;
|
||||
for (it = _overlays2D.begin(); it != _overlays2D.end(); ++it) {
|
||||
delete _overlays2D.take(it.key());
|
||||
}
|
||||
for (it = _overlays3D.begin(); it != _overlays3D.end(); ++it) {
|
||||
delete _overlays3D.take(it.key());
|
||||
}
|
||||
while (!_overlaysToDelete.isEmpty()) {
|
||||
delete _overlaysToDelete.takeLast();
|
||||
}
|
||||
}
|
||||
|
||||
void Overlays::init(QGLWidget* parent) {
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
void Overlays::update(float deltatime) {
|
||||
foreach (Overlay* thisOverlay, _overlays2D) {
|
||||
thisOverlay->update(deltatime);
|
||||
}
|
||||
foreach (Overlay* thisOverlay, _overlays3D) {
|
||||
thisOverlay->update(deltatime);
|
||||
}
|
||||
while (!_overlaysToDelete.isEmpty()) {
|
||||
delete _overlaysToDelete.takeLast();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Overlays::render2D() {
|
||||
foreach(Overlay* thisOverlay, _overlays2D) {
|
||||
thisOverlay->render();
|
||||
|
@ -73,8 +94,8 @@ unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& prope
|
|||
thisOverlay->setProperties(properties);
|
||||
created = true;
|
||||
is3D = true;
|
||||
} else if (type == "clipboard") {
|
||||
thisOverlay = new ClipboardOverlay();
|
||||
} else if (type == "localvoxels") {
|
||||
thisOverlay = new LocalVoxelsOverlay();
|
||||
thisOverlay->init(_parent);
|
||||
thisOverlay->setProperties(properties);
|
||||
created = true;
|
||||
|
@ -111,11 +132,16 @@ bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
|
|||
|
||||
// TODO: make multi-threaded safe
|
||||
void Overlays::deleteOverlay(unsigned int id) {
|
||||
Overlay* overlayToDelete;
|
||||
if (_overlays2D.contains(id)) {
|
||||
_overlays2D.erase(_overlays2D.find(id));
|
||||
overlayToDelete = _overlays2D.take(id);
|
||||
} else if (_overlays3D.contains(id)) {
|
||||
_overlays3D.erase(_overlays3D.find(id));
|
||||
overlayToDelete = _overlays3D.take(id);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
_overlaysToDelete.push_back(overlayToDelete);
|
||||
}
|
||||
|
||||
unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
Overlays();
|
||||
~Overlays();
|
||||
void init(QGLWidget* parent);
|
||||
void update(float deltatime);
|
||||
void render3D();
|
||||
void render2D();
|
||||
|
||||
|
@ -38,7 +39,8 @@ public slots:
|
|||
private:
|
||||
QMap<unsigned int, Overlay*> _overlays2D;
|
||||
QMap<unsigned int, Overlay*> _overlays3D;
|
||||
static unsigned int _nextOverlayID;
|
||||
QList<Overlay*> _overlaysToDelete;
|
||||
unsigned int _nextOverlayID;
|
||||
QGLWidget* _parent;
|
||||
};
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ find_package(Qt5Script REQUIRED)
|
|||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Script)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
|
@ -24,3 +22,5 @@ link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
|||
# link in the hifi voxels library
|
||||
link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
||||
link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Script)
|
|
@ -13,4 +13,4 @@ find_package(Qt5Network REQUIRED)
|
|||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Network)
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network)
|
|
@ -8,8 +8,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm
|
|||
|
||||
set(TARGET_NAME metavoxels)
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Network Script Widgets)
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
@ -17,8 +16,8 @@ auto_mtc(${TARGET_NAME} "${ROOT_DIR}")
|
|||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}")
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Network Script Widgets)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script)
|
||||
|
||||
|
|
|
@ -450,6 +450,13 @@ public:
|
|||
bool operator==(const X& first, const X& second); \
|
||||
bool operator!=(const X& first, const X& second); \
|
||||
static const int* _TypePtr##X = &X::Type;
|
||||
#elif __GNUC__
|
||||
#define DECLARE_STREAMABLE_METATYPE(X) Q_DECLARE_METATYPE(X) \
|
||||
Bitstream& operator<<(Bitstream& out, const X& obj); \
|
||||
Bitstream& operator>>(Bitstream& in, X& obj); \
|
||||
bool operator==(const X& first, const X& second); \
|
||||
bool operator!=(const X& first, const X& second); \
|
||||
__attribute__((unused)) static const int* _TypePtr##X = &X::Type;
|
||||
#else
|
||||
#define STRINGIFY(x) #x
|
||||
#define DECLARE_STREAMABLE_METATYPE(X) Q_DECLARE_METATYPE(X) \
|
||||
|
|
|
@ -13,8 +13,6 @@ find_package(Qt5Widgets REQUIRED)
|
|||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Widgets)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
|
@ -24,4 +22,5 @@ link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
|||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
include_directories("${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
|
|
@ -590,16 +590,26 @@ bool findRayIntersectionOp(OctreeElement* node, void* extraData) {
|
|||
}
|
||||
|
||||
bool Octree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
OctreeElement*& node, float& distance, BoxFace& face, bool tryLock) {
|
||||
OctreeElement*& node, float& distance, BoxFace& face, Octree::lockType lockType) {
|
||||
RayArgs args = { origin / (float)(TREE_SCALE), direction, node, distance, face };
|
||||
|
||||
if (!tryLock) {
|
||||
bool gotLock = false;
|
||||
if (lockType == Octree::Lock) {
|
||||
lockForRead();
|
||||
gotLock = true;
|
||||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
return args.found; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
if (tryLock && tryLockForRead()) {
|
||||
recurseTreeWithOperation(findRayIntersectionOp, &args);
|
||||
|
||||
recurseTreeWithOperation(findRayIntersectionOp, &args);
|
||||
|
||||
if (gotLock) {
|
||||
unlock();
|
||||
}
|
||||
|
||||
return args.found;
|
||||
}
|
||||
|
||||
|
@ -635,7 +645,7 @@ bool findSpherePenetrationOp(OctreeElement* element, void* extraData) {
|
|||
}
|
||||
|
||||
bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration,
|
||||
void** penetratedObject, bool tryLock) {
|
||||
void** penetratedObject, Octree::lockType lockType) {
|
||||
|
||||
SphereArgs args = {
|
||||
center / (float)(TREE_SCALE),
|
||||
|
@ -644,17 +654,27 @@ bool Octree::findSpherePenetration(const glm::vec3& center, float radius, glm::v
|
|||
false,
|
||||
NULL };
|
||||
penetration = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
if (!tryLock) {
|
||||
|
||||
bool gotLock = false;
|
||||
if (lockType == Octree::Lock) {
|
||||
lockForRead();
|
||||
}
|
||||
if (tryLock && tryLockForRead()) {
|
||||
recurseTreeWithOperation(findSpherePenetrationOp, &args);
|
||||
if (penetratedObject) {
|
||||
*penetratedObject = args.penetratedObject;
|
||||
gotLock = true;
|
||||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
return args.found; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
|
||||
recurseTreeWithOperation(findSpherePenetrationOp, &args);
|
||||
if (penetratedObject) {
|
||||
*penetratedObject = args.penetratedObject;
|
||||
}
|
||||
|
||||
if (gotLock) {
|
||||
unlock();
|
||||
}
|
||||
|
||||
return args.found;
|
||||
}
|
||||
|
||||
|
@ -689,7 +709,7 @@ bool findCapsulePenetrationOp(OctreeElement* node, void* extraData) {
|
|||
}
|
||||
|
||||
bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius,
|
||||
glm::vec3& penetration, bool tryLock) {
|
||||
glm::vec3& penetration, Octree::lockType lockType) {
|
||||
|
||||
CapsuleArgs args = {
|
||||
start / (float)(TREE_SCALE),
|
||||
|
@ -699,11 +719,20 @@ bool Octree::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end
|
|||
false };
|
||||
penetration = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
if (!tryLock) {
|
||||
bool gotLock = false;
|
||||
if (lockType == Octree::Lock) {
|
||||
lockForRead();
|
||||
gotLock = true;
|
||||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
return args.found; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
if (tryLock && tryLockForRead()) {
|
||||
recurseTreeWithOperation(findCapsulePenetrationOp, &args);
|
||||
|
||||
recurseTreeWithOperation(findCapsulePenetrationOp, &args);
|
||||
|
||||
if (gotLock) {
|
||||
unlock();
|
||||
}
|
||||
return args.found;
|
||||
|
@ -732,18 +761,28 @@ bool getElementEnclosingOperation(OctreeElement* element, void* extraData) {
|
|||
return true; // keep looking
|
||||
}
|
||||
|
||||
OctreeElement* Octree::getElementEnclosingPoint(const glm::vec3& point, bool tryLock) {
|
||||
OctreeElement* Octree::getElementEnclosingPoint(const glm::vec3& point, Octree::lockType lockType) {
|
||||
GetElementEnclosingArgs args;
|
||||
args.point = point;
|
||||
args.element = NULL;
|
||||
|
||||
if (!tryLock) {
|
||||
bool gotLock = false;
|
||||
if (lockType == Octree::Lock) {
|
||||
lockForRead();
|
||||
gotLock = true;
|
||||
} else if (lockType == Octree::TryLock) {
|
||||
gotLock = tryLockForRead();
|
||||
if (!gotLock) {
|
||||
return args.element; // if we wanted to tryLock, and we couldn't then just bail...
|
||||
}
|
||||
}
|
||||
if (tryLock && tryLockForRead()) {
|
||||
recurseTreeWithOperation(getElementEnclosingOperation, (void*)&args);
|
||||
|
||||
recurseTreeWithOperation(getElementEnclosingOperation, (void*)&args);
|
||||
|
||||
if (gotLock) {
|
||||
unlock();
|
||||
}
|
||||
|
||||
return args.element;
|
||||
}
|
||||
|
||||
|
|
|
@ -221,16 +221,29 @@ public:
|
|||
void clearDirtyBit() { _isDirty = false; }
|
||||
void setDirtyBit() { _isDirty = true; }
|
||||
|
||||
// Octree does not currently handle its own locking, caller must use these to lock/unlock
|
||||
void lockForRead() { _lock.lockForRead(); }
|
||||
bool tryLockForRead() { return _lock.tryLockForRead(); }
|
||||
void lockForWrite() { _lock.lockForWrite(); }
|
||||
bool tryLockForWrite() { return _lock.tryLockForWrite(); }
|
||||
void unlock() { _lock.unlock(); }
|
||||
// output hints from the encode process
|
||||
typedef enum {
|
||||
Lock,
|
||||
TryLock,
|
||||
NoLock
|
||||
} lockType;
|
||||
|
||||
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
OctreeElement*& node, float& distance, BoxFace& face, bool tryLock = true);
|
||||
OctreeElement*& node, float& distance, BoxFace& face, Octree::lockType lockType = Octree::TryLock);
|
||||
|
||||
bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration,
|
||||
void** penetratedObject = NULL, bool tryLock = true);
|
||||
void** penetratedObject = NULL, Octree::lockType lockType = Octree::TryLock);
|
||||
|
||||
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius,
|
||||
glm::vec3& penetration, bool tryLock = true);
|
||||
glm::vec3& penetration, Octree::lockType lockType = Octree::TryLock);
|
||||
|
||||
OctreeElement* getElementEnclosingPoint(const glm::vec3& point, bool tryLock = true);
|
||||
OctreeElement* getElementEnclosingPoint(const glm::vec3& point, Octree::lockType lockType = Octree::TryLock);
|
||||
|
||||
// Note: this assumes the fileFormat is the HIO individual voxels code files
|
||||
void loadOctreeFile(const char* fileName, bool wantColorRandomizer);
|
||||
|
@ -238,13 +251,7 @@ public:
|
|||
// these will read/write files that match the wireformat, excluding the 'V' leading
|
||||
void writeToSVOFile(const char* filename, OctreeElement* node = NULL);
|
||||
bool readFromSVOFile(const char* filename);
|
||||
|
||||
// Octree does not currently handle its own locking, caller must use these to lock/unlock
|
||||
void lockForRead() { _lock.lockForRead(); }
|
||||
bool tryLockForRead() { return _lock.tryLockForRead(); }
|
||||
void lockForWrite() { _lock.lockForWrite(); }
|
||||
bool tryLockForWrite() { return _lock.tryLockForWrite(); }
|
||||
void unlock() { _lock.unlock(); }
|
||||
|
||||
|
||||
unsigned long getOctreeElementsCount();
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ find_package(Qt5Widgets REQUIRED)
|
|||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Widgets)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
|
@ -25,4 +23,5 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
|||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
include_directories("${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
|
|
@ -58,7 +58,7 @@ bool ParticleCollisionSystem::updateOperation(OctreeElement* element, void* extr
|
|||
|
||||
void ParticleCollisionSystem::update() {
|
||||
// update all particles
|
||||
if (_particles->tryLockForWrite()) {
|
||||
if (_particles->tryLockForRead()) {
|
||||
_particles->recurseTreeWithOperation(updateOperation, this);
|
||||
_particles->unlock();
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void ParticleCollisionSystem::updateCollisionWithParticles(Particle* particleA)
|
|||
const float COLLISION_FREQUENCY = 0.5f;
|
||||
glm::vec3 penetration;
|
||||
Particle* particleB;
|
||||
if (_particles->findSpherePenetration(center, radius, penetration, (void**)&particleB)) {
|
||||
if (_particles->findSpherePenetration(center, radius, penetration, (void**)&particleB, Octree::NoLock)) {
|
||||
// NOTE: 'penetration' is the depth that 'particleA' overlaps 'particleB'.
|
||||
// That is, it points from A into B.
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ find_package(Qt5Widgets REQUIRED)
|
|||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Widgets)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
|
@ -27,4 +25,5 @@ link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}")
|
|||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
include_directories("${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets)
|
||||
|
|
153
libraries/script-engine/src/LocalVoxels.cpp
Normal file
153
libraries/script-engine/src/LocalVoxels.cpp
Normal file
|
@ -0,0 +1,153 @@
|
|||
//
|
||||
// LocalVoxels.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/24/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include "LocalVoxels.h"
|
||||
|
||||
LocalVoxels::LocalVoxels(QString name) :
|
||||
QObject(NULL),
|
||||
_name(name),
|
||||
_tree(new VoxelTree(true))
|
||||
{
|
||||
LocalVoxelsList::getInstance()->insert(_name, _tree);
|
||||
}
|
||||
|
||||
LocalVoxels::~LocalVoxels() {
|
||||
_tree.clear();
|
||||
LocalVoxelsList::getInstance()->remove(_name);
|
||||
}
|
||||
|
||||
VoxelDetail LocalVoxels::getVoxelAt(float x, float y, float z, float scale) {
|
||||
// setup a VoxelDetail struct with the data
|
||||
VoxelDetail result = {0,0,0,0,0,0,0};
|
||||
if (_tree) {
|
||||
_tree->lockForRead();
|
||||
|
||||
VoxelTreeElement* voxel = static_cast<VoxelTreeElement*>(_tree->getOctreeElementAt(x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
scale / (float)TREE_SCALE));
|
||||
_tree->unlock();
|
||||
if (voxel) {
|
||||
// Note: these need to be in voxel space because the VoxelDetail -> js converter will upscale
|
||||
result.x = voxel->getCorner().x;
|
||||
result.y = voxel->getCorner().y;
|
||||
result.z = voxel->getCorner().z;
|
||||
result.s = voxel->getScale();
|
||||
result.red = voxel->getColor()[RED_INDEX];
|
||||
result.green = voxel->getColor()[GREEN_INDEX];
|
||||
result.blue = voxel->getColor()[BLUE_INDEX];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void LocalVoxels::setVoxelNonDestructive(float x, float y, float z, float scale,
|
||||
uchar red, uchar green, uchar blue) {
|
||||
if (_name == DOMAIN_TREE_NAME) {
|
||||
qDebug() << "LocalVoxels::setVoxelNonDestructive(): Please use the \"Voxels\" interface to modify the domain tree.";
|
||||
return;
|
||||
}
|
||||
if (_tree ) {
|
||||
_tree->createVoxel(x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
scale / (float)TREE_SCALE,
|
||||
red, green, blue, false);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalVoxels::setVoxel(float x, float y, float z, float scale,
|
||||
uchar red, uchar green, uchar blue) {
|
||||
if (_name == DOMAIN_TREE_NAME) {
|
||||
qDebug() << "LocalVoxels::setVoxel(): Please use the \"Voxels\" interface to modify the domain tree.";
|
||||
return;
|
||||
}
|
||||
if (_tree ) {
|
||||
_tree->createVoxel(x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
scale / (float)TREE_SCALE,
|
||||
red, green, blue, true);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalVoxels::eraseVoxel(float x, float y, float z, float scale) {
|
||||
if (_name == DOMAIN_TREE_NAME) {
|
||||
qDebug() << "LocalVoxels::eraseVoxel(): Please use the \"Voxels\" interface to modify the domain tree.";
|
||||
return;
|
||||
}
|
||||
if (_tree ) {
|
||||
_tree->deleteVoxelAt(x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
scale / (float)TREE_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalVoxels::copyTo(float x, float y, float z, float scale, const QString destination) {
|
||||
if (destination == DOMAIN_TREE_NAME) {
|
||||
qDebug() << "LocalVoxels::copyTo(): Please use the \"Voxels\" interface to modify the domain tree.";
|
||||
return;
|
||||
}
|
||||
StrongVoxelTreePointer destinationTree = LocalVoxelsList::getInstance()->getTree(destination);
|
||||
VoxelTreeElement* destinationNode = destinationTree->getVoxelAt(x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
scale / (float)TREE_SCALE);
|
||||
destinationTree->copyFromTreeIntoSubTree(_tree.data(), destinationNode);
|
||||
}
|
||||
|
||||
void LocalVoxels::pasteFrom(float x, float y, float z, float scale, const QString source) {
|
||||
if (_name == DOMAIN_TREE_NAME) {
|
||||
qDebug() << "LocalVoxels::pasteFrom(): Please use the \"Voxels\" interface to modify the domain tree.";
|
||||
return;
|
||||
}
|
||||
StrongVoxelTreePointer sourceTree = LocalVoxelsList::getInstance()->getTree(source);
|
||||
VoxelTreeElement* sourceNode = _tree->getVoxelAt(x / (float)TREE_SCALE,
|
||||
y / (float)TREE_SCALE,
|
||||
z / (float)TREE_SCALE,
|
||||
scale / (float)TREE_SCALE);
|
||||
_tree->copySubTreeIntoNewTree(sourceNode, sourceTree.data(), true);
|
||||
}
|
||||
|
||||
RayToVoxelIntersectionResult LocalVoxels::findRayIntersection(const PickRay& ray) {
|
||||
RayToVoxelIntersectionResult result;
|
||||
if (_tree) {
|
||||
OctreeElement* element;
|
||||
result.intersects = _tree->findRayIntersection(ray.origin, ray.direction, element, result.distance, result.face);
|
||||
if (result.intersects) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
result.voxel.x = voxel->getCorner().x;
|
||||
result.voxel.y = voxel->getCorner().y;
|
||||
result.voxel.z = voxel->getCorner().z;
|
||||
result.voxel.s = voxel->getScale();
|
||||
result.voxel.red = voxel->getColor()[0];
|
||||
result.voxel.green = voxel->getColor()[1];
|
||||
result.voxel.blue = voxel->getColor()[2];
|
||||
result.intersection = ray.origin + (ray.direction * result.distance);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
glm::vec3 LocalVoxels::getFaceVector(const QString& face) {
|
||||
if (face == "MIN_X_FACE") {
|
||||
return glm::vec3(-1, 0, 0);
|
||||
} else if (face == "MAX_X_FACE") {
|
||||
return glm::vec3(1, 0, 0);
|
||||
} else if (face == "MIN_Y_FACE") {
|
||||
return glm::vec3(0, -1, 0);
|
||||
} else if (face == "MAX_Y_FACE") {
|
||||
return glm::vec3(0, 1, 0);
|
||||
} else if (face == "MIN_Z_FACE") {
|
||||
return glm::vec3(0, 0, -1);
|
||||
} else if (face == "MAX_Z_FACE") {
|
||||
return glm::vec3(0, 0, 1);
|
||||
}
|
||||
return glm::vec3(0, 0, 0); //error case
|
||||
}
|
90
libraries/script-engine/src/LocalVoxels.h
Normal file
90
libraries/script-engine/src/LocalVoxels.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
//
|
||||
// LocalVoxels.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/24/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __hifi__LocalVoxels__
|
||||
#define __hifi__LocalVoxels__
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <RegisteredMetaTypes.h>
|
||||
#include <LocalVoxelsList.h>
|
||||
|
||||
|
||||
/// object allowing JS scripters to use their own local trees
|
||||
class LocalVoxels : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LocalVoxels(QString name);
|
||||
~LocalVoxels();
|
||||
|
||||
/// checks the local voxel tree for a voxel at the specified location and scale
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
/// \param y the y-coordinate of the voxel (in meter units)
|
||||
/// \param z the z-coordinate of the voxel (in meter units)
|
||||
/// \param scale the scale of the voxel (in meter units)
|
||||
Q_INVOKABLE VoxelDetail getVoxelAt(float x, float y, float z, float scale);
|
||||
|
||||
/// creates a non destructive voxel in the local tree
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
/// \param y the y-coordinate of the voxel (in meter units)
|
||||
/// \param z the z-coordinate of the voxel (in meter units)
|
||||
/// \param scale the scale of the voxel (in meter units)
|
||||
/// \param red the R value for RGB color of voxel
|
||||
/// \param green the G value for RGB color of voxel
|
||||
/// \param blue the B value for RGB color of voxel
|
||||
Q_INVOKABLE void setVoxelNonDestructive(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
|
||||
|
||||
/// creates a voxel in the local tree
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
/// \param y the y-coordinate of the voxel (in meter units)
|
||||
/// \param z the z-coordinate of the voxel (in meter units)
|
||||
/// \param scale the scale of the voxel (in meter units)
|
||||
/// \param red the R value for RGB color of voxel
|
||||
/// \param green the G value for RGB color of voxel
|
||||
/// \param blue the B value for RGB color of voxel
|
||||
Q_INVOKABLE void setVoxel(float x, float y, float z, float scale, uchar red, uchar green, uchar blue);
|
||||
|
||||
/// erase the voxel and its children at the given coordinate
|
||||
/// \param x the x-coordinate of the voxel (in meter units)
|
||||
/// \param y the y-coordinate of the voxel (in meter units)
|
||||
/// \param z the z-coordinate of the voxel (in meter units)
|
||||
/// \param scale the scale of the voxel (in meter units)
|
||||
Q_INVOKABLE void eraseVoxel(float x, float y, float z, float scale);
|
||||
|
||||
/// copy the given subtree onto destination's root node
|
||||
/// \param x the x-coordinate of the subtree (in meter units)
|
||||
/// \param y the y-coordinate of the subtree (in meter units)
|
||||
/// \param z the z-coordinate of the subtree (in meter units)
|
||||
/// \param scale the scale of the subtree (in meter units)
|
||||
/// \param destination LocalVoxels' destination tree
|
||||
Q_INVOKABLE void copyTo(float x, float y, float z, float scale, const QString destination);
|
||||
|
||||
///copy source in the given subtree
|
||||
/// \param x the x-coordinate of the subtree (in meter units)
|
||||
/// \param y the y-coordinate of the subtree (in meter units)
|
||||
/// \param z the z-coordinate of the subtree (in meter units)
|
||||
/// \param scale the scale of the subtree (in meter units)
|
||||
/// \param source LocalVoxels' source tree
|
||||
Q_INVOKABLE void pasteFrom(float x, float y, float z, float scale, const QString source);
|
||||
|
||||
/// If the scripting context has visible voxels, this will determine a ray intersection
|
||||
Q_INVOKABLE RayToVoxelIntersectionResult findRayIntersection(const PickRay& ray);
|
||||
|
||||
/// returns a voxel space axis aligned vector for the face, useful in doing voxel math
|
||||
Q_INVOKABLE glm::vec3 getFaceVector(const QString& face);
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
StrongVoxelTreePointer _tree;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* defined(__hifi__LocalVoxels__) */
|
|
@ -25,6 +25,7 @@
|
|||
#include <Sound.h>
|
||||
|
||||
#include "MenuItemProperties.h"
|
||||
#include "LocalVoxels.h"
|
||||
#include "ScriptEngine.h"
|
||||
|
||||
const unsigned int VISUAL_DATA_CALLBACK_USECS = (1.0 / 60.0) * 1000 * 1000;
|
||||
|
@ -118,6 +119,7 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents) {
|
|||
}
|
||||
|
||||
Q_SCRIPT_DECLARE_QMETAOBJECT(AudioInjectorOptions, QObject*)
|
||||
Q_SCRIPT_DECLARE_QMETAOBJECT(LocalVoxels, QString)
|
||||
|
||||
void ScriptEngine::init() {
|
||||
if (_isInitialized) {
|
||||
|
@ -146,6 +148,9 @@ void ScriptEngine::init() {
|
|||
|
||||
QScriptValue injectionOptionValue = _engine.scriptValueFromQMetaObject<AudioInjectorOptions>();
|
||||
_engine.globalObject().setProperty("AudioInjectionOptions", injectionOptionValue);
|
||||
|
||||
QScriptValue localVoxelsValue = _engine.scriptValueFromQMetaObject<LocalVoxels>();
|
||||
_engine.globalObject().setProperty("LocalVoxels", localVoxelsValue);
|
||||
|
||||
registerGlobalObject("Script", this);
|
||||
registerGlobalObject("Audio", &_audioScriptingInterface);
|
||||
|
|
|
@ -6,14 +6,11 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
|||
set(TARGET_NAME shared)
|
||||
project(${TARGET_NAME})
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Network Widgets)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Network Widgets)
|
||||
|
||||
# include GLM
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
@ -31,3 +28,5 @@ if (UNIX AND NOT APPLE)
|
|||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}")
|
||||
endif (UNIX AND NOT APPLE)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets)
|
|
@ -62,10 +62,7 @@ Node::Node(const QUuid& uuid, char type, const HifiSockAddr& publicSocket, const
|
|||
}
|
||||
|
||||
Node::~Node() {
|
||||
if (_linkedData) {
|
||||
delete _linkedData;
|
||||
}
|
||||
|
||||
delete _linkedData;
|
||||
delete _bytesReceivedMovingAverage;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm
|
|||
|
||||
set(TARGET_NAME voxels)
|
||||
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5Script REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Widgets Script)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiLibrary.cmake)
|
||||
setup_hifi_library(${TARGET_NAME})
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Widgets Script)
|
||||
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
|
@ -26,4 +23,5 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}")
|
|||
# link ZLIB
|
||||
find_package(ZLIB)
|
||||
include_directories("${ZLIB_INCLUDE_DIRS}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script)
|
||||
|
|
64
libraries/voxels/src/LocalVoxelsList.cpp
Normal file
64
libraries/voxels/src/LocalVoxelsList.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// LocalVoxelsList.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/24/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include "LocalVoxelsList.h"
|
||||
|
||||
static void doNothing(VoxelTree* t) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
LocalVoxelsList* LocalVoxelsList::_instance = NULL;
|
||||
|
||||
LocalVoxelsList* LocalVoxelsList::getInstance() {
|
||||
if (!_instance) {
|
||||
_instance = new LocalVoxelsList();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
LocalVoxelsList::LocalVoxelsList() {
|
||||
}
|
||||
|
||||
LocalVoxelsList::~LocalVoxelsList() {
|
||||
_instance = NULL;
|
||||
}
|
||||
|
||||
StrongVoxelTreePointer LocalVoxelsList::getTree(QString treeName) {
|
||||
return _trees.value(treeName);
|
||||
}
|
||||
|
||||
void LocalVoxelsList::addPersistantTree(QString treeName, VoxelTree* tree) {
|
||||
StrongVoxelTreePointer treePtr(tree, doNothing);
|
||||
_persistantTrees.push_back(treePtr);
|
||||
_trees.insert(treeName, treePtr);
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : added persistant tree (" << treeName << ")";
|
||||
}
|
||||
|
||||
void LocalVoxelsList::insert(QString treeName, StrongVoxelTreePointer& tree) {
|
||||
// If the key don't already exist or the value is null
|
||||
if (!_trees.contains(treeName) || !_trees.value(treeName)) {
|
||||
_trees.insert(treeName, tree);
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : added local tree (" << treeName << ")";
|
||||
} else {
|
||||
// if not we replace the tree created by the user with the existing one
|
||||
tree = _trees.value(treeName);
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : local tree already exist (" << treeName << ")";
|
||||
}
|
||||
}
|
||||
|
||||
void LocalVoxelsList::remove(QString treeName) {
|
||||
// if the tree is not used anymore (no strong pointer)
|
||||
if (!_trees.value(treeName)) {
|
||||
// then remove it from the list
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : removed unused tree (" << treeName << ")";
|
||||
_trees.remove(treeName);
|
||||
} else {
|
||||
qDebug() << "[DEBUG] LocalVoxelsList : tree still in use (" << treeName << ")";
|
||||
}
|
||||
}
|
59
libraries/voxels/src/LocalVoxelsList.h
Normal file
59
libraries/voxels/src/LocalVoxelsList.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// LocalVoxelsList.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 2/24/14.
|
||||
// Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef __hifi__LocalVoxelsList__
|
||||
#define __hifi__LocalVoxelsList__
|
||||
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
#include <QWeakPointer>
|
||||
|
||||
#include "VoxelTree.h"
|
||||
|
||||
typedef QSharedPointer<VoxelTree> StrongVoxelTreePointer;
|
||||
typedef QWeakPointer<VoxelTree> WeakVoxelTreePointer;
|
||||
|
||||
static const QString DOMAIN_TREE_NAME = "domain";
|
||||
static const QString CLIPBOARD_TREE_NAME = "clipboard";
|
||||
static const QString IMPORT_TREE_NAME = "import";
|
||||
|
||||
/// Handles the the storage and cleanup of local named trees used by JS
|
||||
class LocalVoxelsList {
|
||||
public:
|
||||
static LocalVoxelsList* getInstance();
|
||||
~LocalVoxelsList();
|
||||
|
||||
/// Lookup up a tree in the QHash and return a strong pointer to it.
|
||||
/// \param treeName name of the tree to look up
|
||||
StrongVoxelTreePointer getTree(QString treeName);
|
||||
|
||||
/// Add a that will stay in the list until destruction of the instance and won't be destroyed then either.
|
||||
/// \param treeName name to give to the tree in the list
|
||||
/// \param tree standard pointer to the tree
|
||||
void addPersistantTree(QString treeName, VoxelTree* tree);
|
||||
|
||||
/// insert a local tree in the list
|
||||
/// \param treeName name to give to the tree in the list
|
||||
/// \param tree strong pointer to the tree
|
||||
void insert(QString treeName, StrongVoxelTreePointer& tree);
|
||||
|
||||
/// remove a tree from the list if it's not being used anymore
|
||||
/// \param treeName name of the tree to remove
|
||||
void remove(QString treeName);
|
||||
|
||||
private:
|
||||
static LocalVoxelsList* _instance;
|
||||
LocalVoxelsList();
|
||||
|
||||
QHash<QString, WeakVoxelTreePointer> _trees;
|
||||
|
||||
QList<StrongVoxelTreePointer> _persistantTrees;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__LocalVoxelsList__) */
|
|
@ -61,15 +61,7 @@ foreach(EXTERNAL_SOURCE_SUBDIR ${EXTERNAL_SOURCE_SUBDIRS})
|
|||
set(APPLICATION_SRCS ${APPLICATION_SRCS} "${SUBDIR_SRCS}")
|
||||
endforeach(EXTERNAL_SOURCE_SUBDIR)
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Gui REQUIRED)
|
||||
find_package(Qt5Multimedia REQUIRED)
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5OpenGL REQUIRED)
|
||||
find_package(Qt5Svg REQUIRED)
|
||||
find_package(Qt5WebKit REQUIRED)
|
||||
find_package(Qt5WebKitWidgets REQUIRED)
|
||||
find_package(Qt5Xml REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools)
|
||||
|
||||
# grab the ui files in resources/ui
|
||||
file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
|
||||
|
@ -122,8 +114,6 @@ link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
|||
find_package(GLM REQUIRED)
|
||||
find_package(ZLIB)
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools)
|
||||
|
||||
# include headers for interface
|
||||
include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes")
|
||||
|
||||
|
@ -131,7 +121,9 @@ include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes"
|
|||
# use system flag so warnings are supressed
|
||||
include_directories(SYSTEM "${GLM_INCLUDE_DIRS}")
|
||||
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}")
|
||||
target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}"
|
||||
Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL
|
||||
Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools)
|
||||
|
||||
if (APPLE)
|
||||
# link in required OS X frameworks and include the right GL headers
|
||||
|
|
|
@ -267,7 +267,10 @@ void SvoViewer::InitializeVoxelOpt2RenderSystem()
|
|||
delete [] _readVertexStructs;
|
||||
//delete [] _readIndicesArray;
|
||||
delete [] faceCenters;
|
||||
for (int k = 0; k < NUM_CUBE_FACES; k++) if (_segmentIdxBuffers[i].idxBuff[k]) delete [] _segmentIdxBuffers[i].idxBuff[k];
|
||||
|
||||
for (int k = 0; k < NUM_CUBE_FACES; k++) {
|
||||
delete[] _segmentIdxBuffers[i].idxBuff[k];
|
||||
}
|
||||
}
|
||||
|
||||
_voxelOptRenderInitialized = true;
|
||||
|
|
|
@ -8,9 +8,7 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros")
|
|||
# setup for find modules
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/")
|
||||
|
||||
find_package(Qt5Network REQUIRED)
|
||||
find_package(Qt5Script REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Network Script Widgets)
|
||||
|
||||
include(${MACRO_DIR}/AutoMTC.cmake)
|
||||
auto_mtc(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
@ -18,8 +16,6 @@ auto_mtc(${TARGET_NAME} "${ROOT_DIR}")
|
|||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}")
|
||||
|
||||
qt5_use_modules(${TARGET_NAME} Network Script Widgets)
|
||||
|
||||
#include glm
|
||||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
@ -33,3 +29,5 @@ IF (WIN32)
|
|||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script)
|
||||
|
||||
|
|
|
@ -12,12 +12,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake
|
|||
include(${MACRO_DIR}/IncludeGLM.cmake)
|
||||
include_glm(${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
||||
find_package(Qt5Script REQUIRED)
|
||||
|
||||
include(${MACRO_DIR}/SetupHifiProject.cmake)
|
||||
setup_hifi_project(${TARGET_NAME} TRUE)
|
||||
|
||||
find_package(Qt5Script REQUIRED)
|
||||
qt5_use_modules(${TARGET_NAME} Script)
|
||||
|
||||
# link in the shared library
|
||||
include(${MACRO_DIR}/LinkHifiLibrary.cmake)
|
||||
link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}")
|
||||
|
@ -31,3 +30,5 @@ link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}")
|
|||
IF (WIN32)
|
||||
target_link_libraries(${TARGET_NAME} Winmm Ws2_32)
|
||||
ENDIF(WIN32)
|
||||
|
||||
target_link_libraries(${TARGET_NAME} Qt5::Script)
|
Loading…
Reference in a new issue