Merge branch 'master' of github.com:highfidelity/hifi into island

This commit is contained in:
Seth Alves 2015-04-09 09:59:00 -07:00
commit 66ea6f4eb4
16 changed files with 103 additions and 81 deletions

View file

@ -84,6 +84,7 @@ var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus";
var SETTING_SHOW_LIGHTS_IN_EDIT_MODE = "showLightsInEditMode";
var INSUFFICIENT_PERMISSIONS_ERROR_MSG = "You do not have the necessary permissions to edit on this domain."
var INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG = "You do not have the necessary permissions to place items on this domain."
var modelURLs = [
"Insert the URL to your FBX"
@ -134,12 +135,19 @@ var toolBar = (function () {
newSphereButton,
newLightButton,
newTextButton,
browseModelsButton;
browseMarketplaceButton;
function initialize() {
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL);
// Hide active button for now - this may come back, so not deleting yet.
browseMarketplaceButton = toolBar.addTool({
imageURL: toolIconUrl + "marketplace.svg",
width: toolWidth,
height: toolHeight,
alpha: 0.9,
visible: true,
});
activeButton = toolBar.addTool({
imageURL: toolIconUrl + "edit-status.svg",
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
@ -158,14 +166,6 @@ var toolBar = (function () {
visible: false
});
browseModelsButton = toolBar.addTool({
imageURL: toolIconUrl + "marketplace.svg",
width: toolWidth,
height: toolHeight,
alpha: 0.9,
visible: false
});
newCubeButton = toolBar.addTool({
imageURL: toolIconUrl + "add-cube.svg",
subImage: { x: 0, y: Tool.IMAGE_WIDTH, width: Tool.IMAGE_WIDTH, height: Tool.IMAGE_HEIGHT },
@ -237,7 +237,6 @@ var toolBar = (function () {
// Sets visibility of tool buttons, excluding the power button
that.showTools = function(doShow) {
toolBar.showTool(newModelButton, doShow);
toolBar.showTool(browseModelsButton, doShow);
toolBar.showTool(newCubeButton, doShow);
toolBar.showTool(newSphereButton, doShow);
toolBar.showTool(newLightButton, doShow);
@ -309,7 +308,7 @@ var toolBar = (function () {
};
var newModelButtonDown = false;
var browseModelsButtonDown = false;
var browseMarketplaceButtonDown = false;
that.mousePressEvent = function (event) {
var clickedOverlay,
url,
@ -328,7 +327,7 @@ var toolBar = (function () {
newModelButtonDown = true;
return true;
}
if (browseModelsButton === toolBar.clicked(clickedOverlay)) {
if (browseMarketplaceButton === toolBar.clicked(clickedOverlay)) {
if (marketplaceWindow.url != MARKETPLACE_URL) {
marketplaceWindow.setURL(MARKETPLACE_URL);
}
@ -338,7 +337,7 @@ var toolBar = (function () {
}
if (newCubeButton === toolBar.clicked(clickedOverlay)) {
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
var position = getPositionToCreateEntity();
if (position.x > 0 && position.y > 0 && position.z > 0) {
placingEntityID = Entities.addEntity({
@ -355,7 +354,7 @@ var toolBar = (function () {
}
if (newSphereButton === toolBar.clicked(clickedOverlay)) {
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
var position = getPositionToCreateEntity();
if (position.x > 0 && position.y > 0 && position.z > 0) {
placingEntityID = Entities.addEntity({
@ -371,7 +370,7 @@ var toolBar = (function () {
}
if (newLightButton === toolBar.clicked(clickedOverlay)) {
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
var position = getPositionToCreateEntity();
if (position.x > 0 && position.y > 0 && position.z > 0) {
placingEntityID = Entities.addEntity({
@ -395,7 +394,7 @@ var toolBar = (function () {
if (newTextButton === toolBar.clicked(clickedOverlay)) {
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
var position = getPositionToCreateEntity();
if (position.x > 0 && position.y > 0 && position.z > 0) {
placingEntityID = Entities.addEntity({
@ -427,9 +426,9 @@ var toolBar = (function () {
}
handled = true;
}
} else if (browseModelsButtonDown) {
} else if (browseMarketplaceButtonDown) {
var clickedOverlay = Overlays.getOverlayAtPoint({ x: event.x, y: event.y });
if (browseModelsButton === toolBar.clicked(clickedOverlay)) {
if (browseMarketplaceButton === toolBar.clicked(clickedOverlay)) {
url = Window.s3Browse(".*(fbx|FBX|obj|OBJ)");
if (url !== null && url !== "") {
addModel(url);
@ -439,7 +438,7 @@ var toolBar = (function () {
}
newModelButtonDown = false;
browseModelsButtonDown = false;
browseMarketplaceButtonDown = false;
return handled;
}
@ -947,21 +946,32 @@ function handeMenuEvent(menuItem) {
tooltip.show(false);
}
function getPositionToCreateEntity() {
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
var direction = Quat.getFront(Camera.orientation);
var offset = Vec3.multiply(distance, direction);
var position = Vec3.sum(Camera.position, offset);
position.x = Math.max(0, position.x);
position.y = Math.max(0, position.y);
position.z = Math.max(0, position.z);
return position;
}
function importSVO(importURL) {
if (!Entities.canAdjustLocks()) {
Window.alert(INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG);
return;
}
Overlays.editOverlay(importingSVOTextOverlay, { visible: true });
Overlays.editOverlay(importingSVOImageOverlay, { visible: true });
var success = Clipboard.importEntities(importURL);
if (success) {
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
var direction = Quat.getFront(Camera.orientation);
var offset = Vec3.multiply(distance, direction);
var position = Vec3.sum(Camera.position, offset);
position.x = Math.max(0, position.x);
position.y = Math.max(0, position.y);
position.z = Math.max(0, position.z);
var position = getPositionToCreateEntity();
var pastedEntityIDs = Clipboard.pasteEntities(position);

View file

@ -517,17 +517,17 @@
</div>
</div>
<div class="property">
<div class="label">Locked</div>
<div class="value">
<span class="label">Locked</span>
<span class="value">
<input type='checkbox' id="property-locked">
</div>
</span>
</div>
<div class="property">
<div class="label">Visible</div>
<div class="value">
<span class="label">Visible</span>
<span class="value">
<input type='checkbox' id="property-visible">
</div>
</span>
</div>
<div class="property">
@ -625,17 +625,17 @@
</div>
<div class="property">
<div class="label">Ignore For Collisions</div>
<div class="value">
<span class="label">Ignore For Collisions</span>
<span class="value">
<input type='checkbox' id="property-ignore-for-collisions"></input>
</div>
</span>
</div>
<div class="property">
<div class="label">Collisions Will Move</div>
<div class="value">
<span class="label">Collisions Will Move</span>
<span class="value">
<input type='checkbox' id="property-collisions-will-move"></input>
</div>
</span>
</div>
<div class="property">
@ -690,10 +690,10 @@
</div>
</div>
<div class="model-section property">
<div class="label">Animation Playing</div>
<div class="value">
<span class="label">Animation Playing</span>
<span class="value">
<input type='checkbox' id="property-model-animation-playing">
</div>
</span>
</div>
<div class="model-section property">
<div class="label">Animation FPS</div>
@ -768,10 +768,10 @@
</div>
<div class="light-section property">
<div class="label">Spot Light</div>
<div class="value">
<span class="label">Spot Light</span>
<span class="value">
<input type='checkbox' id="property-light-spot-light">
</div>
</span>
</div>
<div class="light-section property">
<div class="label">Color</div>

View file

@ -194,6 +194,10 @@ input:disabled, textarea:disabled {
color: rgb(160, 160, 160);
}
#properties-list input[type=checkbox] {
vertical-align: bottom;
}
#properties-list input[type=button] {
cursor: pointer;
background-color: rgb(51, 102, 102);
@ -210,8 +214,8 @@ input:disabled, textarea:disabled {
}
#properties-list .property {
padding: 6pt 6pt;
border-top: 0.75pt solid rgb(63, 63, 63);
padding: 4pt;
border-bottom: 0.75pt solid rgb(63, 63, 63);
min-height: 1em;
}
@ -225,10 +229,6 @@ table#properties-list {
table-layout: fixed;
}
#properties-list > div {
margin: 3pt 0;
}
#properties-list {
border-bottom: 0.75pt solid #e5e5e5;
}

View file

@ -640,6 +640,7 @@ void MyAvatar::saveData() {
settings.setValue("firstFrame", pointer->getFirstFrame());
settings.setValue("lastFrame", pointer->getLastFrame());
settings.setValue("maskedJoints", pointer->getMaskedJoints());
settings.setValue("running", pointer->getLoop() && pointer->isRunning());
}
settings.endArray();
@ -713,6 +714,9 @@ void MyAvatar::loadData() {
handle->setFirstFrame(settings.value("firstFrame", 0.0f).toFloat());
handle->setLastFrame(settings.value("lastFrame", INT_MAX).toFloat());
handle->setMaskedJoints(settings.value("maskedJoints").toStringList());
if (settings.value("loop", true).toBool() && settings.value("running", false).toBool()) {
handle->setRunning(true);
}
}
settings.endArray();

View file

@ -212,6 +212,7 @@ void Renderer::glUpload(GLsizei numStars) {
void Renderer::glBatch(GLfloat const* matrix, GLsizei n_ranges, float alpha) {
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
// setup modelview matrix
glPushMatrix();

View file

@ -96,7 +96,7 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo
QHBoxLayout* urlBox = new QHBoxLayout();
layout->addRow("URL:", urlBox);
urlBox->addWidget(_url = new QLineEdit(handle->getURL().toString()), 1);
connect(_url, SIGNAL(returnPressed()), SLOT(updateHandle()));
connect(_url, SIGNAL(editingFinished()), SLOT(updateHandle()));
QPushButton* chooseURL = new QPushButton("Choose");
urlBox->addWidget(chooseURL);
connect(chooseURL, SIGNAL(clicked(bool)), SLOT(chooseURL()));
@ -118,7 +118,7 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo
QHBoxLayout* maskedJointBox = new QHBoxLayout();
layout->addRow("Masked Joints:", maskedJointBox);
maskedJointBox->addWidget(_maskedJoints = new QLineEdit(handle->getMaskedJoints().join(", ")), 1);
connect(_maskedJoints, SIGNAL(returnPressed()), SLOT(updateHandle()));
connect(_maskedJoints, SIGNAL(editingFinished()), SLOT(updateHandle()));
maskedJointBox->addWidget(_chooseMaskedJoints = new QPushButton("Choose"));
connect(_chooseMaskedJoints, SIGNAL(clicked(bool)), SLOT(chooseMaskedJoints()));
@ -168,7 +168,7 @@ void AnimationPanel::chooseURL() {
}
_animationDirectory.set(QFileInfo(filename).path());
_url->setText(QUrl::fromLocalFile(filename).toString());
emit _url->returnPressed();
emit _url->editingFinished();
}
void AnimationPanel::chooseMaskedJoints() {

View file

@ -113,7 +113,7 @@ AttachmentPanel::AttachmentPanel(AttachmentsDialog* dialog, const AttachmentData
layout->addRow("Model URL:", urlBox);
urlBox->addWidget(_modelURL = new QLineEdit(data.modelURL.toString()), 1);
_modelURL->setText(data.modelURL.toString());
connect(_modelURL, SIGNAL(returnPressed()), SLOT(modelURLChanged()));
connect(_modelURL, SIGNAL(editingFinished()), SLOT(modelURLChanged()));
QPushButton* chooseURL = new QPushButton("Choose");
urlBox->addWidget(chooseURL);
connect(chooseURL, SIGNAL(clicked(bool)), SLOT(chooseModelURL()));

View file

@ -201,7 +201,7 @@
#define COPY_PROPERTY_FROM_QSCRIPTVALUE_STRING(P, S)\
QScriptValue P = object.property(#P); \
if (P.isValid()) { \
QString newValue = P.toVariant().toString();\
QString newValue = P.toVariant().toString().trimmed();\
if (_defaultSettings || newValue != _##P) { \
S(newValue); \
} \

View file

@ -95,35 +95,36 @@ void GLBackend::renderBatch(Batch& batch) {
backend.render(batch);
}
void GLBackend::checkGLError() {
bool GLBackend::checkGLError(const char* name) {
GLenum error = glGetError();
if (!error) {
return;
return false;
}
else {
switch (error) {
case GL_INVALID_ENUM:
qCDebug(gpulogging) << "An unacceptable value is specified for an enumerated argument.The offending command is ignored and has no other side effect than to set the error flag.";
qCDebug(gpulogging) << "GLBackend::" << name << ": An unacceptable value is specified for an enumerated argument.The offending command is ignored and has no other side effect than to set the error flag.";
break;
case GL_INVALID_VALUE:
qCDebug(gpulogging) << "A numeric argument is out of range.The offending command is ignored and has no other side effect than to set the error flag";
qCDebug(gpulogging) << "GLBackend" << name << ": A numeric argument is out of range.The offending command is ignored and has no other side effect than to set the error flag";
break;
case GL_INVALID_OPERATION:
qCDebug(gpulogging) << "The specified operation is not allowed in the current state.The offending command is ignored and has no other side effect than to set the error flag..";
qCDebug(gpulogging) << "GLBackend" << name << ": The specified operation is not allowed in the current state.The offending command is ignored and has no other side effect than to set the error flag..";
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
qCDebug(gpulogging) << "The framebuffer object is not complete.The offending command is ignored and has no other side effect than to set the error flag.";
qCDebug(gpulogging) << "GLBackend" << name << ": The framebuffer object is not complete.The offending command is ignored and has no other side effect than to set the error flag.";
break;
case GL_OUT_OF_MEMORY:
qCDebug(gpulogging) << "There is not enough memory left to execute the command.The state of the GL is undefined, except for the state of the error flags, after this error is recorded.";
qCDebug(gpulogging) << "GLBackend" << name << ": There is not enough memory left to execute the command.The state of the GL is undefined, except for the state of the error flags, after this error is recorded.";
break;
case GL_STACK_UNDERFLOW:
qCDebug(gpulogging) << "An attempt has been made to perform an operation that would cause an internal stack to underflow.";
qCDebug(gpulogging) << "GLBackend" << name << ": An attempt has been made to perform an operation that would cause an internal stack to underflow.";
break;
case GL_STACK_OVERFLOW:
qCDebug(gpulogging) << "An attempt has been made to perform an operation that would cause an internal stack to overflow.";
qCDebug(gpulogging) << "GLBackend" << name << ": An attempt has been made to perform an operation that would cause an internal stack to overflow.";
break;
}
return true;
}
}

View file

@ -31,7 +31,7 @@ public:
static void renderBatch(Batch& batch);
static void checkGLError();
static bool checkGLError(const char* name = nullptr);
static bool makeProgram(Shader& shader, const Shader::BindingSet& bindings = Shader::BindingSet());

View file

@ -50,9 +50,9 @@ static const GLenum _elementTypeToGLType[NUM_TYPES]= {
};
#if _DEBUG
#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError()
#define CHECK_GL_ERROR() ::gpu::GLBackend::checkGLError(__FUNCTION__)
#else
#define CHECK_GL_ERROR()
#define CHECK_GL_ERROR() false
#endif
#endif

View file

@ -598,9 +598,14 @@ void GLBackend::do_setStateDepthTest(State::DepthTest test) {
} else {
glDisable(GL_DEPTH_TEST);
}
CHECK_GL_ERROR();
if (CHECK_GL_ERROR()) {
qDebug() << "DepthTest" << (test.isEnabled() ? "Enabled" : "Disabled")
<< "Mask=" << (test.getWriteMask() ? "Write" : "no Write")
<< "Func=" << test.getFunction()
<< "Raw=" << test.getRaw();
}
_pipeline._stateCache.depthTest = test;
_pipeline._stateCache.depthTest = test;
}
}
@ -712,7 +717,7 @@ void GLBackend::do_setStateBlend(State::BlendFunction function) {
}
void GLBackend::do_setStateColorWriteMask(uint32 mask) {
if (_pipeline._stateCache.colorWriteMask = mask) {
if (_pipeline._stateCache.colorWriteMask != mask) {
glColorMask(mask & State::ColorMask::WRITE_RED,
mask & State::ColorMask::WRITE_GREEN,
mask & State::ColorMask::WRITE_BLUE,

View file

@ -27,9 +27,9 @@ Resource::Size Resource::Sysmem::allocateMemory(Byte** dataAllocated, Size size)
if (size > 0) {
// Try allocating as much as the required size + one block of memory
newSize = size;
(*dataAllocated) = new Byte[newSize];
// Failed?
if (!(*dataAllocated)) {
try {
(*dataAllocated) = new Byte[newSize];
} catch (const std::bad_alloc&) {
qWarning() << "Buffer::Sysmem::allocate() : Can't allocate a system memory buffer of " << newSize << "bytes. Fails to create the buffer Sysmem.";
return NOT_ALLOCATED;
}

View file

@ -127,10 +127,11 @@ public:
class DepthTest {
uint8 _function = LESS;
bool _writeMask = true;
bool _enabled = false;
uint8 _writeMask = true;
uint8 _enabled = false;
uint8 _spare;
public:
DepthTest(bool enabled, bool writeMask, ComparisonFunction func) :
DepthTest(bool enabled = false, bool writeMask = true, ComparisonFunction func = LESS) :
_function(func), _writeMask(writeMask), _enabled(enabled) {}
bool isEnabled() const { return _enabled; }

View file

@ -1024,7 +1024,7 @@ int Octree::encodeTreeBitstream(OctreeElement* element,
roomForOctalCode = packetData->startSubTree(newCode);
if (newCode) {
delete newCode;
delete[] newCode;
codeLength = numberOfThreeBitSectionsInCode(newCode);
} else {
codeLength = 1;
@ -2064,7 +2064,7 @@ bool Octree::readJSONFromStream(unsigned long streamLength, QDataStream& inputSt
QVariant asVariant = asDocument.toVariant();
QVariantMap asMap = asVariant.toMap();
readFromMap(asMap);
delete rawData;
delete[] rawData;
return true;
}

View file

@ -64,8 +64,8 @@ void AnimationHandle::setRunning(bool running) {
if (running) {
// move back to the beginning
setFrameIndex(getFirstFrame());
return;
}
return;
}
_animationLoop.setRunning(running);
if (isRunning()) {