Fixed parabola pointers, code cleanup

This commit is contained in:
ksuprynowicz 2023-05-10 16:50:36 +02:00
parent f79ec0f293
commit d74089d7d8
8 changed files with 40 additions and 69 deletions

View file

@ -230,6 +230,7 @@ void ParabolaPointer::RenderState::update(const glm::vec3& origin, const glm::ve
item.updateBounds(); item.updateBounds();
}); });
scene->enqueueTransaction(transaction); scene->enqueueTransaction(transaction);
qDebug() << "ParabolaPointer::RenderState::update";
} }
} }
@ -249,7 +250,7 @@ std::shared_ptr<StartEndRenderState> ParabolaPointer::buildRenderState(const QVa
bool isVisibleInSecondaryCamera = RenderState::ParabolaRenderItem::DEFAULT_PARABOLA_ISVISIBLEINSECONDARYCAMERA; bool isVisibleInSecondaryCamera = RenderState::ParabolaRenderItem::DEFAULT_PARABOLA_ISVISIBLEINSECONDARYCAMERA;
bool drawInFront = RenderState::ParabolaRenderItem::DEFAULT_PARABOLA_DRAWINFRONT; bool drawInFront = RenderState::ParabolaRenderItem::DEFAULT_PARABOLA_DRAWINFRONT;
bool enabled = false; bool enabled = false;
if (propMap["pathPropertyIndex"].isValid()) { /*if (propMap["pathPropertyIndex"].isValid()) {
int pathPropertyIndex = propMap["pathPropertyIndex"].toInt(); int pathPropertyIndex = propMap["pathPropertyIndex"].toInt();
if (pathPropertyIndex >= 0 && pathPropertyIndex < entityProperties.length()) { if (pathPropertyIndex >= 0 && pathPropertyIndex < entityProperties.length()) {
const EntityItemProperties &pathProperties(entityProperties[pathPropertyIndex]); const EntityItemProperties &pathProperties(entityProperties[pathPropertyIndex]);
@ -260,6 +261,30 @@ std::shared_ptr<StartEndRenderState> ParabolaPointer::buildRenderState(const QVa
//width = pathProperties.getWidth; //width = pathProperties.getWidth;
drawInFront = (pathProperties.getRenderLayer() == RenderLayer::FRONT); drawInFront = (pathProperties.getRenderLayer() == RenderLayer::FRONT);
} }
}*/
if (propMap["path"].isValid()) {
enabled = true;
QVariantMap pathMap = propMap["path"].toMap();
if (pathMap["color"].isValid()) {
color = toGlm(u8vec3FromVariant(pathMap["color"]));
}
if (pathMap["alpha"].isValid()) {
alpha = pathMap["alpha"].toFloat();
}
if (pathMap["width"].isValid()) {
width = pathMap["width"].toFloat();
}
if (pathMap["isVisibleInSecondaryCamera"].isValid()) {
isVisibleInSecondaryCamera = pathMap["isVisibleInSecondaryCamera"].toBool();
}
if (pathMap["drawInFront"].isValid()) {
drawInFront = pathMap["drawInFront"].toBool();
}
qDebug() << "ParabolaPointer::buildRenderState";
} }
QUuid endID; QUuid endID;
@ -445,6 +470,7 @@ void ParabolaPointer::RenderState::ParabolaRenderItem::render(RenderArgs* args)
// We draw 2 * n + 2 vertices for a triangle strip // We draw 2 * n + 2 vertices for a triangle strip
batch.draw(gpu::TRIANGLE_STRIP, 2 * _parabolaData.numSections + 2, 0); batch.draw(gpu::TRIANGLE_STRIP, 2 * _parabolaData.numSections + 2, 0);
qDebug() << "ParabolaPointer::RenderState::ParabolaRenderItem::render";
} }
namespace render { namespace render {

View file

@ -144,11 +144,13 @@ void PathPointer::updateVisuals(const PickResultPointer& pickResult) {
auto renderState = _renderStates.find(_currentRenderState); auto renderState = _renderStates.find(_currentRenderState);
auto defaultRenderState = _defaultRenderStates.find(_currentRenderState); auto defaultRenderState = _defaultRenderStates.find(_currentRenderState);
float parentScale = 1.0f; float parentScale = 1.0f;
//if (_scaleWithParent) {
if (_enabled && _scaleWithParent) { if (_enabled && _scaleWithParent) {
glm::vec3 dimensions = DependencyManager::get<PickManager>()->getParentTransform(_pickUID).getScale(); glm::vec3 dimensions = DependencyManager::get<PickManager>()->getParentTransform(_pickUID).getScale();
parentScale = glm::max(glm::max(dimensions.x, dimensions.y), dimensions.z); parentScale = glm::max(glm::max(dimensions.x, dimensions.y), dimensions.z);
} }
//if (!_currentRenderState.empty() && renderState != _renderStates.end() &&
if (_enabled && !_currentRenderState.empty() && renderState != _renderStates.end() && if (_enabled && !_currentRenderState.empty() && renderState != _renderStates.end() &&
(type != IntersectionType::NONE || _pathLength > 0.0f)) { (type != IntersectionType::NONE || _pathLength > 0.0f)) {
glm::vec3 origin = getPickOrigin(pickResult); glm::vec3 origin = getPickOrigin(pickResult);
@ -160,6 +162,7 @@ void PathPointer::updateVisuals(const PickResultPointer& pickResult) {
defaultRenderState->second.second->disable(); defaultRenderState->second.second->disable();
} }
} else if (_enabled && !_currentRenderState.empty() && defaultRenderState != _defaultRenderStates.end()) { } else if (_enabled && !_currentRenderState.empty() && defaultRenderState != _defaultRenderStates.end()) {
//} else if (!_currentRenderState.empty() && defaultRenderState != _defaultRenderStates.end()) {
if (renderState != _renderStates.end() && renderState->second->isEnabled()) { if (renderState != _renderStates.end() && renderState->second->isEnabled()) {
renderState->second->disable(); renderState->second->disable();
} }

View file

@ -677,7 +677,7 @@ bool stylusPointerPropertiesFromScriptValue(const ScriptValue& value, StylusPoin
out.properties[*renderStatesName].setValue(renderStates); out.properties[*renderStatesName].setValue(renderStates);
} }
} }
qDebug() << "rayPointerPropertiesFromScriptValue" << out.properties; qDebug() << "stylusPointerPropertiesFromScriptValue" << out.properties;
return true; return true;
} }
@ -716,6 +716,7 @@ bool parabolaPointerPropertiesFromScriptValue(const ScriptValue& value, Parabola
pathProperties.copyFromScriptValue(path, false); pathProperties.copyFromScriptValue(path, false);
stateMap.insert("pathPropertyIndex", QVariant(out.entityProperties.length())); stateMap.insert("pathPropertyIndex", QVariant(out.entityProperties.length()));
out.entityProperties.append(pathProperties); out.entityProperties.append(pathProperties);
qDebug() << "parabolaPointerPropertiesFromScriptValue : added path entity";
} }
if (stateMap["end"].isValid()) { if (stateMap["end"].isValid()) {
@ -724,6 +725,7 @@ bool parabolaPointerPropertiesFromScriptValue(const ScriptValue& value, Parabola
endProperties.copyFromScriptValue(end, false); endProperties.copyFromScriptValue(end, false);
stateMap.insert("endPropertyIndex", QVariant(out.entityProperties.length())); stateMap.insert("endPropertyIndex", QVariant(out.entityProperties.length()));
out.entityProperties.append(endProperties); out.entityProperties.append(endProperties);
qDebug() << "parabolaPointerPropertiesFromScriptValue : added end entity";
} }
// V8TODO: Check if path is a polyline and if values are valid // V8TODO: Check if path is a polyline and if values are valid
renderStates[i].setValue(stateMap); renderStates[i].setValue(stateMap);
@ -732,6 +734,6 @@ bool parabolaPointerPropertiesFromScriptValue(const ScriptValue& value, Parabola
out.properties[*renderStatesName].setValue(renderStates); out.properties[*renderStatesName].setValue(renderStates);
} }
} }
qDebug() << "rayPointerPropertiesFromScriptValue" << out.properties; qDebug() << "parabolaPointerPropertiesFromScriptValue" << out.properties;
return true; return true;
} }

View file

@ -1458,7 +1458,7 @@ void ScriptSignalV8Proxy::disconnect(ScriptValue arg0, ScriptValue arg1) {
// For debugging // For debugging
ScriptSignalV8Proxy* thisProxy = dynamic_cast<ScriptSignalV8Proxy*>(ScriptObjectV8Proxy::unwrapProxy(v8ThisObject)->toQObject()); ScriptSignalV8Proxy* thisProxy = dynamic_cast<ScriptSignalV8Proxy*>(ScriptObjectV8Proxy::unwrapProxy(v8ThisObject)->toQObject());
Q_ASSERT(thisProxy); Q_ASSERT(thisProxy);
qCDebug(scriptengine_v8) << "ScriptSignalV8Proxy::disconnect: " << thisProxy->fullName() << " fullName: " << fullName(); //qCDebug(scriptengine_v8) << "ScriptSignalV8Proxy::disconnect: " << thisProxy->fullName() << " fullName: " << fullName();
if (!destFunction->Get(destFunctionContext, destDataName).ToLocal(&destData)) { if (!destFunction->Get(destFunctionContext, destDataName).ToLocal(&destData)) {
Q_ASSERT(false); Q_ASSERT(false);
} }
@ -1472,21 +1472,18 @@ void ScriptSignalV8Proxy::disconnect(ScriptValue arg0, ScriptValue arg1) {
v8::Local<v8::Value> entry = destArray->Get(destFunctionContext, idx).ToLocalChecked(); v8::Local<v8::Value> entry = destArray->Get(destFunctionContext, idx).ToLocalChecked();
// For debugging: // For debugging:
{ {
_engine->logBacktrace("ScriptSignalV8Proxy::disconnect"); //qCDebug(scriptengine_v8) << "ScriptSignalV8Proxy::disconnect: entry details: " << _engine->scriptValueDebugDetailsV8(V8ScriptValue(_engine, entry))
qCDebug(scriptengine_v8) << "ScriptSignalV8Proxy::disconnect: entry details: " << _engine->scriptValueDebugDetailsV8(V8ScriptValue(_engine, entry)) // << " Array: " << _engine->scriptValueDebugDetailsV8(V8ScriptValue(_engine, destArray));
<< " Array: " << _engine->scriptValueDebugDetailsV8(V8ScriptValue(_engine, destArray));
Q_ASSERT(entry->IsObject()); Q_ASSERT(entry->IsObject());
V8ScriptValue v8EntryObject(_engine, entry); V8ScriptValue v8EntryObject(_engine, entry);
Q_ASSERT(ScriptObjectV8Proxy::unwrapProxy(v8EntryObject)); Q_ASSERT(ScriptObjectV8Proxy::unwrapProxy(v8EntryObject));
// For debugging // For debugging
ScriptSignalV8Proxy* entryProxy = dynamic_cast<ScriptSignalV8Proxy*>(ScriptObjectV8Proxy::unwrapProxy(v8EntryObject)->toQObject()); //ScriptSignalV8Proxy* entryProxy = dynamic_cast<ScriptSignalV8Proxy*>(ScriptObjectV8Proxy::unwrapProxy(v8EntryObject)->toQObject());
Q_ASSERT(thisProxy); Q_ASSERT(thisProxy);
qCDebug(scriptengine_v8) << "ScriptSignalV8Proxy::disconnect: entry proxy: " << entryProxy->fullName(); //qCDebug(scriptengine_v8) << "ScriptSignalV8Proxy::disconnect: entry proxy: " << entryProxy->fullName();
} }
if (entry->StrictEquals(v8ThisObject.get())) { if (entry->StrictEquals(v8ThisObject.get())) {
//V8TODO: compare proxies instead?
foundIt = true; foundIt = true;
qCDebug(scriptengine_v8) << "ScriptSignalV8Proxy::disconnect foundIt";
} else { } else {
if (!newArray->Set(destFunctionContext, newIndex, entry).FromMaybe(false)) { if (!newArray->Set(destFunctionContext, newIndex, entry).FromMaybe(false)) {
Q_ASSERT(false); Q_ASSERT(false);

View file

@ -646,10 +646,8 @@ bool ScriptValueV8Wrapper::isError() const {
} }
auto errorObj = v8::Local<v8::Object>::Cast(error); auto errorObj = v8::Local<v8::Object>::Cast(error);
if (_value.constGet()->InstanceOf(context, errorObj).FromMaybe(false)) { if (_value.constGet()->InstanceOf(context, errorObj).FromMaybe(false)) {
qDebug() << "ScriptValueV8Wrapper::isError : true";
return true; return true;
} }
qDebug() << "ScriptValueV8Wrapper::isError : false";
return false; return false;
} }

View file

@ -36,7 +36,6 @@ var DEFAULT_SCRIPTS_COMBINED = [
"system/audioMuteOverlay.js", "system/audioMuteOverlay.js",
"system/inspect.js", "system/inspect.js",
"system/keyboardShortcuts/keyboardShortcuts.js", "system/keyboardShortcuts/keyboardShortcuts.js",
"system/checkForUpdates.js",
"system/onEscape.js", "system/onEscape.js",
"system/onFirstRun.js", "system/onFirstRun.js",
"system/appreciate/appreciate_app.js", "system/appreciate/appreciate_app.js",

View file

@ -1,54 +0,0 @@
// checkForUpdates.js
//
// Created by Kalila L. on 8/27/20
// Copyright 2020 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Script.include("/~/system/libraries/utils.js");
var networkingConstants = Script.require("./libraries/networkingConstants.js");
// We'll want a way to specify this later, auto detection can also be a thing, but strictly optional.
var currentBuildType = "latest";
var currentVersion = About.buildVersion;
// Notification Variables
var NOTIFICATION_CHANNEL = "System-Notifications";
var NOTIFICATION_TYPE = "Update-Notification";
var NOTIFICATION_CATEGORY = "Interface";
var notificationText = "An update is available: ";
var notificationColor = { red: 137, green: 63, blue: 255 };
function retrieveMetadata() {
var requireMetadata = Script.require(networkingConstants.INTERFACE_METADATA_SOURCE + '?' + Date.now());
if (requireMetadata) {
return requireMetadata;
} else {
return false;
}
}
function checkForUpdates() {
var vircadiaMetadata = retrieveMetadata();
// Don't check for updates on a dev build.
if (vircadiaMetadata && currentVersion !== "dev") {
var checkVersion = semanticVersionCompare(currentVersion, vircadiaMetadata[currentBuildType].version);
// An update is available!
if (checkVersion === -1) {
Messages.sendMessage(NOTIFICATION_CHANNEL, JSON.stringify({
type: NOTIFICATION_TYPE,
category: NOTIFICATION_CATEGORY,
channel: "Local",
position: MyAvatar.position,
colour: notificationColor,
message: notificationText + vircadiaMetadata[currentBuildType].version,
}));
}
}
}
checkForUpdates();

View file

@ -77,8 +77,8 @@ var HOME_BUTTON_TEXTURE = Script.getExternalPath(Script.ExternalPaths.HF_Content
if (button) { if (button) {
button.clicked.disconnect(onClicked); button.clicked.disconnect(onClicked);
}
tablet.removeButton(button); tablet.removeButton(button);
}
tablet.screenChanged.disconnect(onScreenChanged); tablet.screenChanged.disconnect(onScreenChanged);
}); });
}()); }());