From d20d594ae5b01420b48630bef3da89322bc29079 Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 31 May 2018 10:50:54 -0700 Subject: [PATCH 01/26] use setCollisionEnabled for avatar collisions --- scripts/system/libraries/entitySelectionTool.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index d03d4477f7..cb5d510598 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -313,8 +313,6 @@ SelectionDisplay = (function() { var CTRL_KEY_CODE = 16777249; - var AVATAR_COLLISIONS_OPTION = "Enable Avatar Collisions"; - var TRANSLATE_DIRECTION = { X : 0, Y : 1, @@ -1811,7 +1809,7 @@ SelectionDisplay = (function() { that.restoreAvatarCollisionsFromStretch = function() { if (handleStretchCollisionOverride) { - Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, true); + MyAvatar.setCollisionsEnabled(true); handleStretchCollisionOverride = false; } } @@ -2018,8 +2016,8 @@ SelectionDisplay = (function() { if (scaleHandle != null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED }); } - if (Menu.isOptionChecked(AVATAR_COLLISIONS_OPTION)) { - Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, false); + if (MyAvatar.getCollisionsEnabled()) { + MyAvatar.setCollisionsEnabled(false); handleStretchCollisionOverride = true; } }; From cde111d6012476acd4bd66655efedc1f415cf46a Mon Sep 17 00:00:00 2001 From: David Back Date: Tue, 12 Jun 2018 17:55:04 -0700 Subject: [PATCH 02/26] remove pointing at system overlay and overlay at point checks --- scripts/system/libraries/entitySelectionTool.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 1b41559160..3f9c331b47 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -667,9 +667,6 @@ SelectionDisplay = (function() { activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; } - if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) { - return; - } that.mousePressEvent({}); } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { that.triggered = false; From 9b33e6757f6d33a2057d4b0bfc88a1406bf97599 Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 15 Jun 2018 14:29:47 -0700 Subject: [PATCH 03/26] prevent edit press events when pointing at desktop window or tablet --- .../controllerModules/inEditMode.js | 34 +++++++++++++++++++ .../system/libraries/entitySelectionTool.js | 24 ++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index 5d90898b82..d0c2f94f85 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -18,10 +18,16 @@ Script.include("/~/system/libraries/controllers.js"); Script.include("/~/system/libraries/utils.js"); (function () { + var MARGIN = 25; + function InEditMode(hand) { this.hand = hand; this.triggerClicked = false; this.selectedTarget = null; + this.reticleMinX = MARGIN; + this.reticleMaxX; + this.reticleMinY = MARGIN; + this.reticleMaxY; this.parameters = makeDispatcherModuleParameters( 160, @@ -47,6 +53,16 @@ Script.include("/~/system/libraries/utils.js"); return (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || (HMD.homeButtonID && objectID === HMD.homeButtonID); }; + + this.calculateNewReticlePosition = function(intersection) { + var dims = Controller.getViewportDimensions(); + this.reticleMaxX = dims.x - MARGIN; + this.reticleMaxY = dims.y - MARGIN; + var point2d = HMD.overlayFromWorldPoint(intersection); + point2d.x = Math.max(this.reticleMinX, Math.min(point2d.x, this.reticleMaxX)); + point2d.y = Math.max(this.reticleMinY, Math.min(point2d.y, this.reticleMaxY)); + return point2d; + }; this.sendPickData = function(controllerData) { if (controllerData.triggerClicks[this.hand]) { @@ -72,7 +88,24 @@ Script.include("/~/system/libraries/utils.js"); this.triggerClicked = true; } + + this.sendPointingAtData(controllerData); }; + + this.sendPointingAtData = function(controllerData) { + var rayPick = controllerData.rayPicks[this.hand]; + var hudRayPick = controllerData.hudRayPicks[this.hand]; + var point2d = this.calculateNewReticlePosition(hudRayPick.intersection); + var desktopWindow = Window.isPointOnDesktopWindow(point2d); + var tablet = this.pointingAtTablet(rayPick.objectID); + var rightHand = this.hand === RIGHT_HAND; + Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ + method: "pointingAt", + desktopWindow: desktopWindow, + tablet: tablet, + rightHand: rightHand + })); + }; this.exitModule = function() { return makeRunningValues(false, [], []); @@ -104,6 +137,7 @@ Script.include("/~/system/libraries/utils.js"); if (overlayLaser) { var overlayLaserReady = overlayLaser.isReady(controllerData); var target = controllerData.rayPicks[this.hand].objectID; + this.sendPointingAtData(controllerData); if (overlayLaserReady.active && this.pointingAtTablet(target)) { return this.exitModule(); } diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 3f9c331b47..35ea579824 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -58,6 +58,14 @@ SelectionManager = (function() { that.setSelections([messageParsed.entityID]); } else if (messageParsed.method === "clearSelection") { that.clearSelections(); + } else if (messageParsed.method === "pointingAt") { + if (messageParsed.rightHand) { + that.pointingAtDesktopWindowRight = messageParsed.desktopWindow; + that.pointingAtTabletRight = messageParsed.tablet; + } else { + that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow; + that.pointingAtTabletLeft = messageParsed.tablet; + } } } @@ -93,6 +101,11 @@ SelectionManager = (function() { that.worldDimensions = Vec3.ZERO; that.worldRegistrationPoint = Vec3.HALF; that.centerPosition = Vec3.ZERO; + + that.pointingAtDesktopWindowLeft = false; + that.pointingAtDesktopWindowRight = false; + that.pointingAtTabletLeft = false; + that.pointingAtTabletRight = false; that.saveProperties = function() { that.savedProperties = {}; @@ -667,7 +680,16 @@ SelectionDisplay = (function() { activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; } - that.mousePressEvent({}); + var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand && + SelectionManager.pointingAtDesktopWindowRight) || + (hand === Controller.Standard.LeftHand && + SelectionManager.pointingAtDesktopWindowLeft); + var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) || + (hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft); + if (pointingAtDesktopWindow || pointingAtTablet) { + return; + } + that.mousePressEvent({}); } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { that.triggered = false; that.mouseReleaseEvent({}); From bc06b88afc49cb6074296046a7e5e584f7e4afda Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 15 Jun 2018 14:31:18 -0700 Subject: [PATCH 04/26] tabs --- .../controllerModules/inEditMode.js | 42 +++++++++---------- .../system/libraries/entitySelectionTool.js | 40 +++++++++--------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/scripts/system/controllers/controllerModules/inEditMode.js b/scripts/system/controllers/controllerModules/inEditMode.js index d0c2f94f85..a724c2037b 100644 --- a/scripts/system/controllers/controllerModules/inEditMode.js +++ b/scripts/system/controllers/controllerModules/inEditMode.js @@ -18,13 +18,13 @@ Script.include("/~/system/libraries/controllers.js"); Script.include("/~/system/libraries/utils.js"); (function () { - var MARGIN = 25; - + var MARGIN = 25; + function InEditMode(hand) { this.hand = hand; this.triggerClicked = false; this.selectedTarget = null; - this.reticleMinX = MARGIN; + this.reticleMinX = MARGIN; this.reticleMaxX; this.reticleMinY = MARGIN; this.reticleMaxY; @@ -53,7 +53,7 @@ Script.include("/~/system/libraries/utils.js"); return (HMD.tabletScreenID && objectID === HMD.tabletScreenID) || (HMD.homeButtonID && objectID === HMD.homeButtonID); }; - + this.calculateNewReticlePosition = function(intersection) { var dims = Controller.getViewportDimensions(); this.reticleMaxX = dims.x - MARGIN; @@ -88,24 +88,24 @@ Script.include("/~/system/libraries/utils.js"); this.triggerClicked = true; } - - this.sendPointingAtData(controllerData); + + this.sendPointingAtData(controllerData); }; - - this.sendPointingAtData = function(controllerData) { - var rayPick = controllerData.rayPicks[this.hand]; - var hudRayPick = controllerData.hudRayPicks[this.hand]; - var point2d = this.calculateNewReticlePosition(hudRayPick.intersection); - var desktopWindow = Window.isPointOnDesktopWindow(point2d); - var tablet = this.pointingAtTablet(rayPick.objectID); - var rightHand = this.hand === RIGHT_HAND; - Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ - method: "pointingAt", - desktopWindow: desktopWindow, - tablet: tablet, - rightHand: rightHand + + this.sendPointingAtData = function(controllerData) { + var rayPick = controllerData.rayPicks[this.hand]; + var hudRayPick = controllerData.hudRayPicks[this.hand]; + var point2d = this.calculateNewReticlePosition(hudRayPick.intersection); + var desktopWindow = Window.isPointOnDesktopWindow(point2d); + var tablet = this.pointingAtTablet(rayPick.objectID); + var rightHand = this.hand === RIGHT_HAND; + Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ + method: "pointingAt", + desktopWindow: desktopWindow, + tablet: tablet, + rightHand: rightHand })); - }; + }; this.exitModule = function() { return makeRunningValues(false, [], []); @@ -137,7 +137,7 @@ Script.include("/~/system/libraries/utils.js"); if (overlayLaser) { var overlayLaserReady = overlayLaser.isReady(controllerData); var target = controllerData.rayPicks[this.hand].objectID; - this.sendPointingAtData(controllerData); + this.sendPointingAtData(controllerData); if (overlayLaserReady.active && this.pointingAtTablet(target)) { return this.exitModule(); } diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 35ea579824..5769e4fded 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -59,13 +59,13 @@ SelectionManager = (function() { } else if (messageParsed.method === "clearSelection") { that.clearSelections(); } else if (messageParsed.method === "pointingAt") { - if (messageParsed.rightHand) { - that.pointingAtDesktopWindowRight = messageParsed.desktopWindow; - that.pointingAtTabletRight = messageParsed.tablet; - } else { - that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow; - that.pointingAtTabletLeft = messageParsed.tablet; - } + if (messageParsed.rightHand) { + that.pointingAtDesktopWindowRight = messageParsed.desktopWindow; + that.pointingAtTabletRight = messageParsed.tablet; + } else { + that.pointingAtDesktopWindowLeft = messageParsed.desktopWindow; + that.pointingAtTabletLeft = messageParsed.tablet; + } } } @@ -101,11 +101,11 @@ SelectionManager = (function() { that.worldDimensions = Vec3.ZERO; that.worldRegistrationPoint = Vec3.HALF; that.centerPosition = Vec3.ZERO; - - that.pointingAtDesktopWindowLeft = false; - that.pointingAtDesktopWindowRight = false; - that.pointingAtTabletLeft = false; - that.pointingAtTabletRight = false; + + that.pointingAtDesktopWindowLeft = false; + that.pointingAtDesktopWindowRight = false; + that.pointingAtTabletLeft = false; + that.pointingAtTabletRight = false; that.saveProperties = function() { that.savedProperties = {}; @@ -680,16 +680,16 @@ SelectionDisplay = (function() { activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; } - var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand && - SelectionManager.pointingAtDesktopWindowRight) || - (hand === Controller.Standard.LeftHand && - SelectionManager.pointingAtDesktopWindowLeft); - var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) || - (hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft); + var pointingAtDesktopWindow = (hand === Controller.Standard.RightHand && + SelectionManager.pointingAtDesktopWindowRight) || + (hand === Controller.Standard.LeftHand && + SelectionManager.pointingAtDesktopWindowLeft); + var pointingAtTablet = (hand === Controller.Standard.RightHand && SelectionManager.pointingAtTabletRight) || + (hand === Controller.Standard.LeftHand && SelectionManager.pointingAtTabletLeft); if (pointingAtDesktopWindow || pointingAtTablet) { - return; + return; } - that.mousePressEvent({}); + that.mousePressEvent({}); } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { that.triggered = false; that.mouseReleaseEvent({}); From 9ea65950d554369ae14844b604287325dab3b376 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 14 Jun 2018 17:40:55 -0700 Subject: [PATCH 05/26] particles: threadsafe, cleanup, rework initialized logic --- .../RenderableParticleEffectEntityItem.cpp | 4 - .../src/RenderableParticleEffectEntityItem.h | 14 -- .../entities/src/EntityItemProperties.cpp | 45 +++--- libraries/entities/src/EntityItemProperties.h | 12 +- .../entities/src/EntityItemPropertiesMacros.h | 18 +++ .../entities/src/ParticleEffectEntityItem.cpp | 145 ++++++++++-------- .../entities/src/ParticleEffectEntityItem.h | 79 +++++----- .../networking/src/udt/PacketHeaders.cpp | 2 +- libraries/networking/src/udt/PacketHeaders.h | 3 +- 9 files changed, 162 insertions(+), 160 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index 881c39c0bd..a42f69c189 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -95,9 +95,6 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi auto newParticleProperties = entity->getParticleProperties(); if (!newParticleProperties.valid()) { qCWarning(entitiesrenderer) << "Bad particle properties"; - if (!entity->getParticleProperties().valid()) { - qCWarning(entitiesrenderer) << "Bad particle properties"; - } } if (resultWithReadLock([&]{ return _particleProperties != newParticleProperties; })) { @@ -309,7 +306,6 @@ void ParticleEffectEntityRenderer::doRender(RenderArgs* args) { return; } - // FIXME migrate simulation to a compute stage stepSimulation(); diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h index be2641c0c9..e4abaccf43 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h @@ -45,7 +45,6 @@ private: // CPU particles // FIXME either switch to GPU compute particles or switch to simd updating of the particles -#if 1 struct CpuParticle { float seed{ 0.0f }; uint64_t expiration { 0 }; @@ -62,19 +61,6 @@ private: } }; using CpuParticles = std::deque; -#else - struct CpuParticles { - std::vector seeds; - std::vector lifetimes; - std::vector positions; - std::vector velocities; - std::vector accelerations; - - size_t size() const; - void resize(size_t size); - void integrate(float deltaTime); - }; -#endif template diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 84e248b74d..e5ec0223e6 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -879,28 +879,28 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * @property {number} azimuthStart=-Math.PI - The angle in radians from the entity's local x-axis about the entity's local * z-axis at which particles start being emitted; range -Math.PIMath.PI. Particles are * emitted from the portion of the ellipsoid that lies between azimuthStart and azimuthFinish. - * @property {number} azimuthFinish=Math.PI - The angle in radians from the entity's local x-axis about the entity's local - * z-axis at which particles stop being emitted; range -Math.PIMath.PI. Particles are + * @property {number} azimuthFinish=Math.PI - The angle in radians from the entity's local x-axis about the entity's local + * z-axis at which particles stop being emitted; range -Math.PIMath.PI. Particles are * emitted from the portion of the ellipsoid that lies between azimuthStart and azimuthFinish. * - * @property {string} textures="" - The URL of a JPG or PNG image file to display for each particle. If you want transparency, + * @property {string} textures="" - The URL of a JPG or PNG image file to display for each particle. If you want transparency, * use PNG format. * @property {number} particleRadius=0.025 - The radius of each particle at the middle of its life. - * @property {number} radiusStart=0.025 - The radius of each particle at the start of its life. If not explicitly set, the + * @property {number} radiusStart=0.025 - The radius of each particle at the start of its life. If not explicitly set, the * particleRadius value is used. - * @property {number} radiusFinish=0.025 - The radius of each particle at the end of its life. If not explicitly set, the + * @property {number} radiusFinish=0.025 - The radius of each particle at the end of its life. If not explicitly set, the * particleRadius value is used. * @property {number} radiusSpread=0 - Currently not used. * @property {Color} color=255,255,255 - The color of each particle at the middle of its life. - * @property {Color} colorStart=255,255,255 - The color of each particle at the start of its life. If not explicitly set, the + * @property {Color} colorStart=255,255,255 - The color of each particle at the start of its life. If not explicitly set, the * color value is used. - * @property {Color} colorFinish=255,255,255 - The color of each particle at the end of its life. If not explicitly set, the + * @property {Color} colorFinish=255,255,255 - The color of each particle at the end of its life. If not explicitly set, the * color value is used. * @property {Color} colorSpread=0,0,0 - Currently not used. * @property {number} alpha=1 - The alpha of each particle at the middle of its life. - * @property {number} alphaStart=1 - The alpha of each particle at the start of its life. If not explicitly set, the + * @property {number} alphaStart=1 - The alpha of each particle at the start of its life. If not explicitly set, the * alpha value is used. - * @property {number} alphaFinish=1 - The alpha of each particle at the end of its life. If not explicitly set, the + * @property {number} alphaFinish=1 - The alpha of each particle at the end of its life. If not explicitly set, the * alpha value is used. * @property {number} alphaSpread=0 - Currently not used. * @@ -1520,8 +1520,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(canCastShadow, bool, setCanCastShadow); COPY_PROPERTY_FROM_QSCRIPTVALUE(color, xColor, setColor); COPY_PROPERTY_FROM_QSCRIPTVALUE(colorSpread, xColor, setColorSpread); - COPY_PROPERTY_FROM_QSCRIPTVALUE(colorStart, xColor, setColorStart); - COPY_PROPERTY_FROM_QSCRIPTVALUE(colorFinish, xColor, setColorFinish); + COPY_PROPERTY_FROM_QSCRIPTVALUE(colorStart, glmVec3, setColorStart); + COPY_PROPERTY_FROM_QSCRIPTVALUE(colorFinish, glmVec3, setColorFinish); COPY_PROPERTY_FROM_QSCRIPTVALUE(alpha, float, setAlpha); COPY_PROPERTY_FROM_QSCRIPTVALUE(alphaSpread, float, setAlphaSpread); COPY_PROPERTY_FROM_QSCRIPTVALUE(alphaStart, float, setAlphaStart); @@ -1896,8 +1896,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_COLLISION_SOUND_URL, CollisionSoundURL, collisionSoundURL, QString); ADD_PROPERTY_TO_MAP(PROP_COLOR, Color, color, xColor); ADD_PROPERTY_TO_MAP(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor); - ADD_PROPERTY_TO_MAP(PROP_COLOR_START, ColorStart, colorStart, xColor); - ADD_PROPERTY_TO_MAP(PROP_COLOR_FINISH, ColorFinish, colorFinish, xColor); + ADD_PROPERTY_TO_MAP(PROP_COLOR_START, ColorStart, colorStart, vec3); + ADD_PROPERTY_TO_MAP(PROP_COLOR_FINISH, ColorFinish, colorFinish, vec3); ADD_PROPERTY_TO_MAP(PROP_ALPHA, Alpha, alpha, float); ADD_PROPERTY_TO_MAP(PROP_ALPHA_SPREAD, AlphaSpread, alphaSpread, float); ADD_PROPERTY_TO_MAP(PROP_ALPHA_START, AlphaStart, alphaStart, float); @@ -2660,8 +2660,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_RADIUS_START, float, setRadiusStart); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_RADIUS_FINISH, float, setRadiusFinish); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR_SPREAD, xColor, setColorSpread); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR_START, xColor, setColorStart); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR_FINISH, xColor, setColorFinish); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR_START, vec3, setColorStart); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR_FINISH, vec3, setColorFinish); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA_SPREAD, float, setAlphaSpread); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA_START, float, setAlphaStart); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA_FINISH, float, setAlphaFinish); @@ -2955,15 +2955,12 @@ void EntityItemProperties::markAllChanged() { _radiusSpreadChanged = true; _colorSpreadChanged = true; _alphaSpreadChanged = true; - - // Only mark the following as changed if their values are specified in the properties when the particle is created. If their - // values are specified then they are marked as changed in getChangedProperties(). - //_radiusStartChanged = true; - //_radiusFinishChanged = true; - //_colorStartChanged = true; - //_colorFinishChanged = true; - //_alphaStartChanged = true; - //_alphaFinishChanged = true; + _radiusStartChanged = true; + _radiusFinishChanged = true; + _colorStartChanged = true; + _colorFinishChanged = true; + _alphaStartChanged = true; + _alphaFinishChanged = true; _materialURLChanged = true; _materialMappingModeChanged = true; diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index e46eb73910..a44c718441 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -134,14 +134,14 @@ public: DEFINE_PROPERTY_REF(PROP_SCRIPT, Script, script, QString, ENTITY_ITEM_DEFAULT_SCRIPT); DEFINE_PROPERTY(PROP_SCRIPT_TIMESTAMP, ScriptTimestamp, scriptTimestamp, quint64, ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP); DEFINE_PROPERTY_REF(PROP_COLLISION_SOUND_URL, CollisionSoundURL, collisionSoundURL, QString, ENTITY_ITEM_DEFAULT_COLLISION_SOUND_URL); - DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor, particle::DEFAULT_COLOR); - DEFINE_PROPERTY_REF(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor, particle::DEFAULT_COLOR_SPREAD); - DEFINE_PROPERTY_REF(PROP_COLOR_START, ColorStart, colorStart, xColor, particle::DEFAULT_COLOR); - DEFINE_PROPERTY_REF(PROP_COLOR_FINISH, ColorFinish, colorFinish, xColor, particle::DEFAULT_COLOR); + DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor, particle::DEFAULT_XCOLOR); + DEFINE_PROPERTY_REF(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor, particle::DEFAULT_XCOLOR_SPREAD); + DEFINE_PROPERTY_REF(PROP_COLOR_START, ColorStart, colorStart, vec3, particle::DEFAULT_COLOR_UNINITIALIZED); + DEFINE_PROPERTY_REF(PROP_COLOR_FINISH, ColorFinish, colorFinish, vec3, particle::DEFAULT_COLOR_UNINITIALIZED); DEFINE_PROPERTY(PROP_ALPHA, Alpha, alpha, float, particle::DEFAULT_ALPHA); DEFINE_PROPERTY(PROP_ALPHA_SPREAD, AlphaSpread, alphaSpread, float, particle::DEFAULT_ALPHA_SPREAD); - DEFINE_PROPERTY(PROP_ALPHA_START, AlphaStart, alphaStart, float, particle::DEFAULT_ALPHA); - DEFINE_PROPERTY(PROP_ALPHA_FINISH, AlphaFinish, alphaFinish, float, particle::DEFAULT_ALPHA); + DEFINE_PROPERTY(PROP_ALPHA_START, AlphaStart, alphaStart, float, particle::DEFAULT_ALPHA_START); + DEFINE_PROPERTY(PROP_ALPHA_FINISH, AlphaFinish, alphaFinish, float, particle::DEFAULT_ALPHA_FINISH); DEFINE_PROPERTY_REF(PROP_MODEL_URL, ModelURL, modelURL, QString, ""); DEFINE_PROPERTY_REF(PROP_COMPOUND_SHAPE_URL, CompoundShapeURL, compoundShapeURL, QString, ""); DEFINE_PROPERTY_REF(PROP_REGISTRATION_POINT, RegistrationPoint, registrationPoint, glm::vec3, ENTITY_ITEM_DEFAULT_REGISTRATION_POINT); diff --git a/libraries/entities/src/EntityItemPropertiesMacros.h b/libraries/entities/src/EntityItemPropertiesMacros.h index 3bbff6cfa6..482f914602 100644 --- a/libraries/entities/src/EntityItemPropertiesMacros.h +++ b/libraries/entities/src/EntityItemPropertiesMacros.h @@ -246,6 +246,15 @@ inline glmVec3 glmVec3_convertFromScriptValue(const QScriptValue& v, bool& isVal QScriptValue x = v.property("x"); QScriptValue y = v.property("y"); QScriptValue z = v.property("z"); + if (!x.isValid()) { + x = v.property("red"); + } + if (!y.isValid()) { + y = v.property("green"); + } + if (!z.isValid()) { + z = v.property("blue"); + } if (x.isValid() && y.isValid() && z.isValid()) { glm::vec3 newValue(0); newValue.x = x.toVariant().toFloat(); @@ -317,6 +326,15 @@ inline xColor xColor_convertFromScriptValue(const QScriptValue& v, bool& isValid QScriptValue r = v.property("red"); QScriptValue g = v.property("green"); QScriptValue b = v.property("blue"); + if (!r.isValid()) { + r = v.property("x"); + } + if (!g.isValid()) { + g = v.property("y"); + } + if (!b.isValid()) { + b = v.property("z"); + } if (r.isValid() && g.isValid() && b.isValid()) { newValue.red = r.toVariant().toInt(); newValue.green = g.toVariant().toInt(); diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index d1fc3d2775..92bd86db92 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -152,18 +152,6 @@ EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID return entity; } -#if 0 -void ParticleEffectEntityItem::checkValid() { - bool result; - withReadLock([&] { - result = _particleProperties.valid(); - }); - if (!result) { - qCWarning(entities) << "Invalid particle properties"; - } -} -#endif - // our non-pure virtual subclass for now... ParticleEffectEntityItem::ParticleEffectEntityItem(const EntityItemID& entityItemID) : EntityItem(entityItemID) @@ -180,15 +168,13 @@ void ParticleEffectEntityItem::setAlpha(float alpha) { void ParticleEffectEntityItem::setAlphaStart(float alphaStart) { withWriteLock([&] { - _particleProperties.alpha.range.start = glm::clamp(alphaStart, MINIMUM_ALPHA, MAXIMUM_ALPHA); - _isAlphaStartInitialized = true; + _particleProperties.alpha.range.start = isnan(alphaStart) ? alphaStart : glm::clamp(alphaStart, MINIMUM_ALPHA, MAXIMUM_ALPHA); }); } void ParticleEffectEntityItem::setAlphaFinish(float alphaFinish) { withWriteLock([&] { - _particleProperties.alpha.range.finish = glm::clamp(alphaFinish, MINIMUM_ALPHA, MAXIMUM_ALPHA); - _isAlphaFinishInitialized = true; + _particleProperties.alpha.range.finish = isnan(alphaFinish) ? alphaFinish : glm::clamp(alphaFinish, MINIMUM_ALPHA, MAXIMUM_ALPHA); }); } @@ -281,15 +267,9 @@ void ParticleEffectEntityItem::setAzimuthFinish(float azimuthFinish) { void ParticleEffectEntityItem::setEmitAcceleration(const glm::vec3& emitAcceleration_) { auto emitAcceleration = glm::clamp(emitAcceleration_, vec3(MINIMUM_EMIT_ACCELERATION), vec3(MAXIMUM_EMIT_ACCELERATION)); if (emitAcceleration != _particleProperties.emission.acceleration.target) { - if (!_particleProperties.valid()) { - qCWarning(entities) << "Bad particle data"; - } withWriteLock([&] { _particleProperties.emission.acceleration.target = emitAcceleration; }); - if (!_particleProperties.valid()) { - qCWarning(entities) << "Bad particle data"; - } computeAndUpdateDimensions(); } } @@ -312,15 +292,13 @@ void ParticleEffectEntityItem::setParticleRadius(float particleRadius) { void ParticleEffectEntityItem::setRadiusStart(float radiusStart) { withWriteLock([&] { - _particleProperties.radius.range.start = glm::clamp(radiusStart, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); - _isRadiusStartInitialized = true; + _particleProperties.radius.range.start = isnan(radiusStart) ? radiusStart : glm::clamp(radiusStart, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); }); } void ParticleEffectEntityItem::setRadiusFinish(float radiusFinish) { withWriteLock([&] { - _particleProperties.radius.range.finish = glm::clamp(radiusFinish, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); - _isRadiusFinishInitialized = true; + _particleProperties.radius.range.finish = isnan(radiusFinish) ? radiusFinish : glm::clamp(radiusFinish, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); }); } @@ -390,7 +368,6 @@ EntityItemProperties ParticleEffectEntityItem::getProperties(EntityPropertyFlags COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures); COPY_ENTITY_PROPERTY_TO_PROPERTIES(emitterShouldTrail, getEmitterShouldTrail); - return properties; } @@ -441,18 +418,26 @@ bool ParticleEffectEntityItem::setProperties(const EntityItemProperties& propert return somethingChanged; } -void ParticleEffectEntityItem::setColor(const rgbColor& value) { - memcpy(_particleColorHack, value, sizeof(rgbColor)); - _particleProperties.color.gradient.target.red = value[RED_INDEX]; - _particleProperties.color.gradient.target.green = value[GREEN_INDEX]; - _particleProperties.color.gradient.target.blue = value[BLUE_INDEX]; +void ParticleEffectEntityItem::setColor(const vec3& value) { + withWriteLock([&] { + _particleProperties.color.gradient.target = value; + }); } void ParticleEffectEntityItem::setColor(const xColor& value) { - _particleProperties.color.gradient.target = value; - _particleColorHack[RED_INDEX] = value.red; - _particleColorHack[GREEN_INDEX] = value.green; - _particleColorHack[BLUE_INDEX] = value.blue; + withWriteLock([&] { + _particleProperties.color.gradient.target.r = value.red; + _particleProperties.color.gradient.target.g = value.green; + _particleProperties.color.gradient.target.b = value.blue; + }); +} + +xColor ParticleEffectEntityItem::getXColor() const { + xColor color; + color.red = _particleProperties.color.gradient.target.r; + color.green = _particleProperties.color.gradient.target.g; + color.blue = _particleProperties.color.gradient.target.b; + return color; } int ParticleEffectEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead, @@ -463,15 +448,15 @@ int ParticleEffectEntityItem::readEntitySubclassDataFromBuffer(const unsigned ch int bytesRead = 0; const unsigned char* dataAt = data; - READ_ENTITY_PROPERTY(PROP_COLOR, rgbColor, setColor); + READ_ENTITY_PROPERTY(PROP_COLOR, xColor, setColor); READ_ENTITY_PROPERTY(PROP_EMITTING_PARTICLES, bool, setIsEmitting); READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, setShapeType); READ_ENTITY_PROPERTY(PROP_MAX_PARTICLES, quint32, setMaxParticles); READ_ENTITY_PROPERTY(PROP_LIFESPAN, float, setLifespan); READ_ENTITY_PROPERTY(PROP_EMIT_RATE, float, setEmitRate); - READ_ENTITY_PROPERTY(PROP_EMIT_ACCELERATION, glm::vec3, setEmitAcceleration); - READ_ENTITY_PROPERTY(PROP_ACCELERATION_SPREAD, glm::vec3, setAccelerationSpread); + READ_ENTITY_PROPERTY(PROP_EMIT_ACCELERATION, vec3, setEmitAcceleration); + READ_ENTITY_PROPERTY(PROP_ACCELERATION_SPREAD, vec3, setAccelerationSpread); READ_ENTITY_PROPERTY(PROP_PARTICLE_RADIUS, float, setParticleRadius); READ_ENTITY_PROPERTY(PROP_TEXTURES, QString, setTextures); @@ -480,8 +465,8 @@ int ParticleEffectEntityItem::readEntitySubclassDataFromBuffer(const unsigned ch READ_ENTITY_PROPERTY(PROP_RADIUS_FINISH, float, setRadiusFinish); READ_ENTITY_PROPERTY(PROP_COLOR_SPREAD, xColor, setColorSpread); - READ_ENTITY_PROPERTY(PROP_COLOR_START, xColor, setColorStart); - READ_ENTITY_PROPERTY(PROP_COLOR_FINISH, xColor, setColorFinish); + READ_ENTITY_PROPERTY(PROP_COLOR_START, vec3, setColorStart); + READ_ENTITY_PROPERTY(PROP_COLOR_FINISH, vec3, setColorFinish); READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha); READ_ENTITY_PROPERTY(PROP_ALPHA_SPREAD, float, setAlphaSpread); READ_ENTITY_PROPERTY(PROP_ALPHA_START, float, setAlphaStart); @@ -489,8 +474,8 @@ int ParticleEffectEntityItem::readEntitySubclassDataFromBuffer(const unsigned ch READ_ENTITY_PROPERTY(PROP_EMIT_SPEED, float, setEmitSpeed); READ_ENTITY_PROPERTY(PROP_SPEED_SPREAD, float, setSpeedSpread); - READ_ENTITY_PROPERTY(PROP_EMIT_ORIENTATION, glm::quat, setEmitOrientation); - READ_ENTITY_PROPERTY(PROP_EMIT_DIMENSIONS, glm::vec3, setEmitDimensions); + READ_ENTITY_PROPERTY(PROP_EMIT_ORIENTATION, quat, setEmitOrientation); + READ_ENTITY_PROPERTY(PROP_EMIT_DIMENSIONS, vec3, setEmitDimensions); READ_ENTITY_PROPERTY(PROP_EMIT_RADIUS_START, float, setEmitRadiusStart); READ_ENTITY_PROPERTY(PROP_POLAR_START, float, setPolarStart); READ_ENTITY_PROPERTY(PROP_POLAR_FINISH, float, setPolarFinish); @@ -548,7 +533,7 @@ void ParticleEffectEntityItem::appendSubclassData(OctreePacketData* packetData, OctreeElement::AppendState& appendState) const { bool successPropertyFits = true; - APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor()); + APPEND_ENTITY_PROPERTY(PROP_COLOR, getXColor()); APPEND_ENTITY_PROPERTY(PROP_EMITTING_PARTICLES, getIsEmitting()); APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType()); APPEND_ENTITY_PROPERTY(PROP_MAX_PARTICLES, getMaxParticles()); @@ -585,10 +570,10 @@ void ParticleEffectEntityItem::appendSubclassData(OctreePacketData* packetData, void ParticleEffectEntityItem::debugDump() const { quint64 now = usecTimestampNow(); qCDebug(entities) << "PA EFFECT EntityItem id:" << getEntityItemID() << "---------------------------------------------"; - qCDebug(entities) << " color:" << - _particleProperties.color.gradient.target.red << "," << - _particleProperties.color.gradient.target.green << "," << - _particleProperties.color.gradient.target.blue; + qCDebug(entities) << " color:" << + _particleProperties.color.gradient.target.r << "," << + _particleProperties.color.gradient.target.g << "," << + _particleProperties.color.gradient.target.b; qCDebug(entities) << " position:" << debugTreeVector(getWorldPosition()); qCDebug(entities) << " dimensions:" << debugTreeVector(getScaledDimensions()); qCDebug(entities) << " getLastEdited:" << debugTime(getLastEdited(), now); @@ -604,15 +589,9 @@ void ParticleEffectEntityItem::setShapeType(ShapeType type) { } void ParticleEffectEntityItem::setMaxParticles(quint32 maxParticles) { - _particleProperties.maxParticles = glm::clamp(maxParticles, MINIMUM_MAX_PARTICLES, MAXIMUM_MAX_PARTICLES); -} - -QString ParticleEffectEntityItem::getTextures() const { - QString result; - withReadLock([&] { - result = _particleProperties.textures; + withWriteLock([&] { + _particleProperties.maxParticles = glm::clamp(maxParticles, MINIMUM_MAX_PARTICLES, MAXIMUM_MAX_PARTICLES); }); - return result; } void ParticleEffectEntityItem::setTextures(const QString& textures) { @@ -621,25 +600,57 @@ void ParticleEffectEntityItem::setTextures(const QString& textures) { }); } +void ParticleEffectEntityItem::setColorStart(const vec3& colorStart) { + withWriteLock([&] { + _particleProperties.color.range.start = colorStart; + }); +} + +void ParticleEffectEntityItem::setColorFinish(const vec3& colorFinish) { + withWriteLock([&] { + _particleProperties.color.range.finish = colorFinish; + }); +} + +void ParticleEffectEntityItem::setColorSpread(const xColor& value) { + withWriteLock([&] { + _particleProperties.color.gradient.spread.r = value.red; + _particleProperties.color.gradient.spread.g = value.green; + _particleProperties.color.gradient.spread.b = value.blue; + }); +} + +xColor ParticleEffectEntityItem::getColorSpread() const { + xColor color; + color.red = _particleProperties.color.gradient.spread.r; + color.green = _particleProperties.color.gradient.spread.g; + color.blue = _particleProperties.color.gradient.spread.b; + return color; +} + +void ParticleEffectEntityItem::setEmitterShouldTrail(bool emitterShouldTrail) { + withWriteLock([&] { + _particleProperties.emission.shouldTrail = emitterShouldTrail; + }); +} + particle::Properties ParticleEffectEntityItem::getParticleProperties() const { particle::Properties result; withReadLock([&] { result = _particleProperties; - }); - // Special case the properties that get treated differently if they're unintialized - result.color.range.start = getColorStart(); - result.color.range.finish = getColorFinish(); - result.alpha.range.start = getAlphaStart(); - result.alpha.range.finish = getAlphaFinish(); - result.radius.range.start = getRadiusStart(); - result.radius.range.finish = getRadiusFinish(); + // Special case the properties that get treated differently if they're unintialized + result.color.range.start = getColorStart(); + result.color.range.finish = getColorFinish(); + result.alpha.range.start = getAlphaStart(); + result.alpha.range.finish = getAlphaFinish(); + result.radius.range.start = getRadiusStart(); + result.radius.range.finish = getRadiusFinish(); + }); if (!result.valid()) { qCWarning(entities) << "failed validation"; } return result; -} - - +} \ No newline at end of file diff --git a/libraries/entities/src/ParticleEffectEntityItem.h b/libraries/entities/src/ParticleEffectEntityItem.h index 9c0fd0ef95..16621d307d 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.h +++ b/libraries/entities/src/ParticleEffectEntityItem.h @@ -19,12 +19,16 @@ namespace particle { static const float SCRIPT_MAXIMUM_PI = 3.1416f; // Round up so that reasonable property values work - static const xColor DEFAULT_COLOR = { 255, 255, 255 }; - static const xColor DEFAULT_COLOR_SPREAD = { 0, 0, 0 }; + static const float UNINITIALIZED = NAN; + static const vec3 DEFAULT_COLOR = { 255, 255, 255 }; + static const xColor DEFAULT_XCOLOR = { DEFAULT_COLOR.r, DEFAULT_COLOR.g, DEFAULT_COLOR.b }; + static const vec3 DEFAULT_COLOR_UNINITIALIZED = { UNINITIALIZED, UNINITIALIZED, UNINITIALIZED }; + static const vec3 DEFAULT_COLOR_SPREAD = { 0, 0, 0 }; + static const xColor DEFAULT_XCOLOR_SPREAD = { DEFAULT_COLOR_SPREAD.r, DEFAULT_COLOR_SPREAD.g, DEFAULT_COLOR_SPREAD.b }; static const float DEFAULT_ALPHA = 1.0f; static const float DEFAULT_ALPHA_SPREAD = 0.0f; - static const float DEFAULT_ALPHA_START = DEFAULT_ALPHA; - static const float DEFAULT_ALPHA_FINISH = DEFAULT_ALPHA; + static const float DEFAULT_ALPHA_START = UNINITIALIZED; + static const float DEFAULT_ALPHA_FINISH = UNINITIALIZED; static const float MINIMUM_ALPHA = 0.0f; static const float MAXIMUM_ALPHA = 1.0f; static const quint32 DEFAULT_MAX_PARTICLES = 1000; @@ -65,8 +69,8 @@ namespace particle { static const float MINIMUM_PARTICLE_RADIUS = 0.0f; static const float MAXIMUM_PARTICLE_RADIUS = (float)TREE_SCALE; static const float DEFAULT_RADIUS_SPREAD = 0.0f; - static const float DEFAULT_RADIUS_START = DEFAULT_PARTICLE_RADIUS; - static const float DEFAULT_RADIUS_FINISH = DEFAULT_PARTICLE_RADIUS; + static const float DEFAULT_RADIUS_START = UNINITIALIZED; + static const float DEFAULT_RADIUS_FINISH = UNINITIALIZED; static const QString DEFAULT_TEXTURES = ""; static const bool DEFAULT_EMITTER_SHOULD_TRAIL = false; @@ -145,12 +149,12 @@ namespace particle { }; struct Properties { - RangeGradient color{ DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_COLOR, DEFAULT_COLOR_SPREAD }; - RangeGradient alpha{ DEFAULT_ALPHA, DEFAULT_ALPHA_START, DEFAULT_ALPHA_FINISH, DEFAULT_ALPHA_SPREAD }; - float radiusStart{ DEFAULT_EMIT_RADIUS_START }; - RangeGradient radius{ DEFAULT_PARTICLE_RADIUS, DEFAULT_RADIUS_START, DEFAULT_RADIUS_FINISH, DEFAULT_RADIUS_SPREAD }; - float lifespan{ DEFAULT_LIFESPAN }; - uint32_t maxParticles{ DEFAULT_MAX_PARTICLES }; + RangeGradient color { DEFAULT_COLOR, DEFAULT_COLOR_UNINITIALIZED, DEFAULT_COLOR_UNINITIALIZED, DEFAULT_COLOR_SPREAD }; + RangeGradient alpha { DEFAULT_ALPHA, DEFAULT_ALPHA_START, DEFAULT_ALPHA_FINISH, DEFAULT_ALPHA_SPREAD }; + float radiusStart { DEFAULT_EMIT_RADIUS_START }; + RangeGradient radius { DEFAULT_PARTICLE_RADIUS, DEFAULT_RADIUS_START, DEFAULT_RADIUS_FINISH, DEFAULT_RADIUS_SPREAD }; + float lifespan { DEFAULT_LIFESPAN }; + uint32_t maxParticles { DEFAULT_MAX_PARTICLES }; EmitProperties emission; Range polar { DEFAULT_POLAR_START, DEFAULT_POLAR_FINISH }; Range azimuth { DEFAULT_AZIMUTH_START, DEFAULT_AZIMUTH_FINISH }; @@ -176,10 +180,10 @@ namespace particle { return *this; } - glm::vec4 getColorStart() const { return glm::vec4(ColorUtils::sRGBToLinearVec3(toGlm(color.range.start)), alpha.range.start); } - glm::vec4 getColorMiddle() const { return glm::vec4(ColorUtils::sRGBToLinearVec3(toGlm(color.gradient.target)), alpha.gradient.target); } - glm::vec4 getColorFinish() const { return glm::vec4(ColorUtils::sRGBToLinearVec3(toGlm(color.range.finish)), alpha.range.finish); } - glm::vec4 getColorSpread() const { return glm::vec4(ColorUtils::sRGBToLinearVec3(toGlm(color.gradient.spread)), alpha.gradient.spread); } + vec4 getColorStart() const { return vec4(ColorUtils::sRGBToLinearVec3(color.range.start / 255.0f), alpha.range.start); } + vec4 getColorMiddle() const { return vec4(ColorUtils::sRGBToLinearVec3(color.gradient.target / 255.0f), alpha.gradient.target); } + vec4 getColorFinish() const { return vec4(ColorUtils::sRGBToLinearVec3(color.range.finish / 255.0f), alpha.range.finish); } + vec4 getColorSpread() const { return vec4(ColorUtils::sRGBToLinearVec3(color.gradient.spread / 255.0f), alpha.gradient.spread); } }; } // namespace particles @@ -215,37 +219,29 @@ public: EntityPropertyFlags& propertyFlags, bool overwriteLocalData, bool& somethingChanged) override; - const rgbColor& getColor() const { return _particleColorHack; } - xColor getXColor() const { return _particleProperties.color.gradient.target; } - glm::vec3 getColorRGB() const { return ColorUtils::sRGBToLinearVec3(toGlm(getXColor())); } + xColor getXColor() const; + vec3 getColor() const { return _particleProperties.color.gradient.target; } - void setColor(const rgbColor& value); + void setColor(const vec3& value); void setColor(const xColor& value); - bool _isColorStartInitialized = false; - void setColorStart(const xColor& colorStart) { _particleProperties.color.range.start = colorStart; _isColorStartInitialized = true; } - xColor getColorStart() const { return _isColorStartInitialized ? _particleProperties.color.range.start : getXColor(); } - glm::vec3 getColorStartRGB() const { return _isColorStartInitialized ? ColorUtils::sRGBToLinearVec3(toGlm(_particleProperties.color.range.start)) : getColorRGB(); } + void setColorStart(const vec3& colorStart); + vec3 getColorStart() const { return any(isnan(_particleProperties.color.range.start)) ? getColor() : _particleProperties.color.range.start; } - bool _isColorFinishInitialized = false; - void setColorFinish(const xColor& colorFinish) { _particleProperties.color.range.finish = colorFinish; _isColorFinishInitialized = true; } - xColor getColorFinish() const { return _isColorFinishInitialized ? _particleProperties.color.range.finish : getXColor(); } - glm::vec3 getColorFinishRGB() const { return _isColorFinishInitialized ? ColorUtils::sRGBToLinearVec3(toGlm(_particleProperties.color.range.finish)) : getColorRGB(); } + void setColorFinish(const vec3& colorFinish); + vec3 getColorFinish() const { return any(isnan(_particleProperties.color.range.finish)) ? getColor() : _particleProperties.color.range.finish; } - void setColorSpread(const xColor& colorSpread) { _particleProperties.color.gradient.spread = colorSpread; } - xColor getColorSpread() const { return _particleProperties.color.gradient.spread; } - glm::vec3 getColorSpreadRGB() const { return ColorUtils::sRGBToLinearVec3(toGlm(_particleProperties.color.gradient.spread)); } + void setColorSpread(const xColor& colorSpread); + xColor getColorSpread() const; void setAlpha(float alpha); float getAlpha() const { return _particleProperties.alpha.gradient.target; } - bool _isAlphaStartInitialized = false; void setAlphaStart(float alphaStart); - float getAlphaStart() const { return _isAlphaStartInitialized ? _particleProperties.alpha.range.start : _particleProperties.alpha.gradient.target; } + float getAlphaStart() const { return isnan(_particleProperties.alpha.range.start) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.start; } - bool _isAlphaFinishInitialized = false; void setAlphaFinish(float alphaFinish); - float getAlphaFinish() const { return _isAlphaFinishInitialized ? _particleProperties.alpha.range.finish : _particleProperties.alpha.gradient.target; } + float getAlphaFinish() const { return isnan(_particleProperties.alpha.range.finish) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.finish; } void setAlphaSpread(float alphaSpread); float getAlphaSpread() const { return _particleProperties.alpha.gradient.spread; } @@ -303,31 +299,28 @@ public: void setParticleRadius(float particleRadius); float getParticleRadius() const { return _particleProperties.radius.gradient.target; } - bool _isRadiusStartInitialized = false; void setRadiusStart(float radiusStart); - float getRadiusStart() const { return _isRadiusStartInitialized ? _particleProperties.radius.range.start : _particleProperties.radius.gradient.target; } + float getRadiusStart() const { return isnan(_particleProperties.radius.range.start) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.start; } - bool _isRadiusFinishInitialized = false; void setRadiusFinish(float radiusFinish); - float getRadiusFinish() const { return _isRadiusFinishInitialized ? _particleProperties.radius.range.finish : _particleProperties.radius.gradient.target; } + float getRadiusFinish() const { return isnan(_particleProperties.radius.range.finish) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.finish; } void setRadiusSpread(float radiusSpread); float getRadiusSpread() const { return _particleProperties.radius.gradient.spread; } void computeAndUpdateDimensions(); - QString getTextures() const; void setTextures(const QString& textures); + QString ParticleEffectEntityItem::getTextures() const { return _particleProperties.textures; } bool getEmitterShouldTrail() const { return _particleProperties.emission.shouldTrail; } - void setEmitterShouldTrail(bool emitterShouldTrail) { _particleProperties.emission.shouldTrail = emitterShouldTrail; } + void setEmitterShouldTrail(bool emitterShouldTrail); virtual bool supportsDetailedRayIntersection() const override { return false; } - particle::Properties getParticleProperties() const; + particle::Properties getParticleProperties() const; protected: - rgbColor _particleColorHack; particle::Properties _particleProperties; bool _isEmitting { true }; diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index c342ecffc5..a77cb68bef 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -33,7 +33,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::EntityEdit: case PacketType::EntityData: case PacketType::EntityPhysics: - return static_cast(EntityVersion::CollisionMask16Bytes); + return static_cast(EntityVersion::ParticleEntityFix); case PacketType::EntityQuery: return static_cast(EntityQueryPacketVersion::ConicalFrustums); case PacketType::AvatarIdentity: diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 64054fd080..594ca3396b 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -236,7 +236,8 @@ enum class EntityVersion : PacketVersion { ShadowControl, MaterialData, CloneableData, - CollisionMask16Bytes + CollisionMask16Bytes, + ParticleEntityFix }; enum class EntityScriptCallMethodVersion : PacketVersion { From f6c624dcc3ad96f8e65b6a83f89c484b7f0b65e5 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Fri, 15 Jun 2018 16:31:09 -0700 Subject: [PATCH 06/26] Remove logging messages for behaviors that are expected. Attached entities with scripts are now being sold on the marketplace (rWatch) and are now being worn by various users. Because of this, it's now common for the 'removing entity scripts' case to be hit in code for every update, which causes debug log messages every 60 seconds for each entity entity with a script. Repro: Have an avatar wear rWatch. With a second instance of interface, turn on verbose logging while the first avatar is local. See debug logging 60 times a second. Fix: Given attached entities with scripts are happening, it's not an exceptional case and should probably not be logged. --- libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 048b8b1633..c257349bff 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -294,7 +294,6 @@ void Avatar::updateAvatarEntities() { // NOTE: if this avatar entity is not attached to us, strip its entity script completely... auto attachedScript = properties.getScript(); if (!isMyAvatar() && !attachedScript.isEmpty()) { - qCDebug(avatars_renderer) << "removing entity script from avatar attached entity:" << entityID << "old script:" << attachedScript; QString noScript; properties.setScript(noScript); } From 6ef8206f3aeb913f14d9ffa164d97b8441d7313a Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 15 Jun 2018 17:32:03 -0700 Subject: [PATCH 07/26] temp disable myAvatar collisions when stretching --- .../system/libraries/entitySelectionTool.js | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index b42ed5cf64..48c8c68f96 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -366,7 +366,7 @@ SelectionDisplay = (function() { var ctrlPressed = false; - var handleStretchCollisionOverride = false; + var replaceCollisionsAfterStretch = false; var handlePropertiesTranslateArrowCones = { shape: "Cone", @@ -642,11 +642,6 @@ SelectionDisplay = (function() { var activeTool = null; var handleTools = {}; - that.shutdown = function() { - that.restoreAvatarCollisionsFromStretch(); - } - Script.scriptEnding.connect(that.shutdown); - // We get mouseMoveEvents from the handControllers, via handControllerPointer. // But we dont' get mousePressEvents. that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click'); @@ -1830,13 +1825,6 @@ SelectionDisplay = (function() { }; }; - that.restoreAvatarCollisionsFromStretch = function() { - if (handleStretchCollisionOverride) { - MyAvatar.setCollisionsEnabled(true); - handleStretchCollisionOverride = false; - } - } - // TOOL DEFINITION: HANDLE STRETCH TOOL function makeStretchTool(stretchMode, directionEnum, directionVec, pivot, offset, stretchPanel, scaleHandle) { var directionFor3DStretch = directionVec; @@ -2039,10 +2027,13 @@ SelectionDisplay = (function() { if (scaleHandle != null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED }); } - if (MyAvatar.getCollisionsEnabled()) { - MyAvatar.setCollisionsEnabled(false); - handleStretchCollisionOverride = true; - } + + var myAvatarIndex = properties.collidesWith.indexOf("myAvatar"); + if (myAvatarIndex > -1) { + var newCollidesWith = properties.collidesWith.replace("myAvatar", ""); + Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); + that.replaceCollisionsAfterStretch = true; + } }; var onEnd = function(event, reason) { @@ -2052,7 +2043,13 @@ SelectionDisplay = (function() { if (scaleHandle != null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE }); } - that.restoreAvatarCollisionsFromStretch(); + + if (that.replaceCollisionsAfterStretch) { + var newCollidesWith = SelectionManager.savedProperties[SelectionManager.selections[0]].collidesWith; + Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); + that.replaceCollisionsAfterStretch = false; + } + pushCommandForSelections(); }; @@ -2138,12 +2135,10 @@ SelectionDisplay = (function() { } var newPosition = Vec3.sum(initialPosition, changeInPosition); - for (var i = 0; i < SelectionManager.selections.length; i++) { - Entities.editEntity(SelectionManager.selections[i], { - position: newPosition, - dimensions: newDimensions - }); - } + Entities.editEntity(SelectionManager.selections[0], { + position: newPosition, + dimensions: newDimensions + }); var wantDebug = false; if (wantDebug) { From d16b7779779ad232d56e989a33a33e0f18923134 Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 15 Jun 2018 17:33:49 -0700 Subject: [PATCH 08/26] tabs --- .../system/libraries/entitySelectionTool.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 48c8c68f96..9da0e813d1 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2027,13 +2027,13 @@ SelectionDisplay = (function() { if (scaleHandle != null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED }); } - - var myAvatarIndex = properties.collidesWith.indexOf("myAvatar"); - if (myAvatarIndex > -1) { - var newCollidesWith = properties.collidesWith.replace("myAvatar", ""); - Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); - that.replaceCollisionsAfterStretch = true; - } + + var myAvatarIndex = properties.collidesWith.indexOf("myAvatar"); + if (myAvatarIndex > -1) { + var newCollidesWith = properties.collidesWith.replace("myAvatar", ""); + Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); + that.replaceCollisionsAfterStretch = true; + } }; var onEnd = function(event, reason) { @@ -2043,13 +2043,13 @@ SelectionDisplay = (function() { if (scaleHandle != null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE }); } - - if (that.replaceCollisionsAfterStretch) { - var newCollidesWith = SelectionManager.savedProperties[SelectionManager.selections[0]].collidesWith; - Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); - that.replaceCollisionsAfterStretch = false; - } - + + if (that.replaceCollisionsAfterStretch) { + var newCollidesWith = SelectionManager.savedProperties[SelectionManager.selections[0]].collidesWith; + Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); + that.replaceCollisionsAfterStretch = false; + } + pushCommandForSelections(); }; @@ -2135,7 +2135,7 @@ SelectionDisplay = (function() { } var newPosition = Vec3.sum(initialPosition, changeInPosition); - Entities.editEntity(SelectionManager.selections[0], { + Entities.editEntity(SelectionManager.selections[0], { position: newPosition, dimensions: newDimensions }); From bb0b1cc4a4589b77be588754a0314f14bf2dd1cc Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 15 Jun 2018 17:35:18 -0700 Subject: [PATCH 09/26] no myAvatarIndex needed --- scripts/system/libraries/entitySelectionTool.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 9da0e813d1..8b1c50b129 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2028,8 +2028,7 @@ SelectionDisplay = (function() { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED }); } - var myAvatarIndex = properties.collidesWith.indexOf("myAvatar"); - if (myAvatarIndex > -1) { + if (properties.collidesWith.indexOf("myAvatar") > -1) { var newCollidesWith = properties.collidesWith.replace("myAvatar", ""); Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); that.replaceCollisionsAfterStretch = true; From 77716619487898b2088f688aeb029bd42516423d Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 15 Jun 2018 17:35:49 -0700 Subject: [PATCH 10/26] fix particle spread properties --- .../RenderableParticleEffectEntityItem.cpp | 5 +- .../src/RenderableParticleEffectEntityItem.h | 2 +- .../src/textured_particle.slv | 7 + .../entities/src/EntityItemProperties.cpp | 1 + .../entities/src/ParticleEffectEntityItem.cpp | 8 +- .../entities/src/ParticleEffectEntityItem.h | 18 +- libraries/gpu/src/gpu/Noise.slh | 297 ++++++++++++++++++ .../src/procedural/ProceduralCommon.slf | 285 +---------------- .../particle_explorer/particleExplorer.js | 6 + 9 files changed, 329 insertions(+), 300 deletions(-) create mode 100644 libraries/gpu/src/gpu/Noise.slh diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index a42f69c189..8cbbf76788 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -186,7 +186,7 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa if (polarStart == 0.0f && polarFinish == 0.0f && emitDimensions.z == 0.0f) { // Emit along z-axis from position - particle.velocity = (emitSpeed + 0.2f * speedSpread) * (emitOrientation * Vectors::UNIT_Z); + particle.velocity = (emitSpeed + randFloatInRange(-1.0f, 1.0f) * speedSpread) * (emitOrientation * Vectors::UNIT_Z); particle.acceleration = emitAcceleration + randFloatInRange(-1.0f, 1.0f) * accelerationSpread; } else { @@ -197,8 +197,7 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa float elevationMinZ = sin(PI_OVER_TWO - polarFinish); float elevationMaxZ = sin(PI_OVER_TWO - polarStart); - // float elevation = asin(elevationMinZ + (elevationMaxZ - elevationMinZ) * randFloat()); - float elevation = asin(elevationMinZ + (elevationMaxZ - elevationMinZ) *randFloat()); + float elevation = asin(elevationMinZ + (elevationMaxZ - elevationMinZ) * randFloat()); float azimuth; if (azimuthFinish >= azimuthStart) { diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h index e4abaccf43..8e9353894a 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h @@ -46,7 +46,7 @@ private: // CPU particles // FIXME either switch to GPU compute particles or switch to simd updating of the particles struct CpuParticle { - float seed{ 0.0f }; + float seed { 0.0f }; uint64_t expiration { 0 }; float lifetime { 0.0f }; glm::vec3 position; diff --git a/libraries/entities-renderer/src/textured_particle.slv b/libraries/entities-renderer/src/textured_particle.slv index 1d4261b1cc..7653bc0a42 100644 --- a/libraries/entities-renderer/src/textured_particle.slv +++ b/libraries/entities-renderer/src/textured_particle.slv @@ -11,6 +11,7 @@ // <@include gpu/Transform.slh@> +<@include gpu/Noise.slh@> <$declareStandardTransform()$> @@ -119,9 +120,15 @@ void main(void) { // Offset for corrected vertex ordering. varTexcoord = vec2((UNIT_QUAD[twoTriID].xy -1.0) * vec2(0.5, -0.5)); varColor = interpolate3Vec4(particle.color.start, particle.color.middle, particle.color.finish, age); + vec3 colorSpread = 2.0 * vec3(hifi_hash(seed), hifi_hash(seed * 2.0), hifi_hash(seed * 3.0)) - 1.0; + varColor.rgb = clamp(varColor.rgb + colorSpread * particle.color.spread.rgb, vec3(0), vec3(1)); + float alphaSpread = 2.0 * hifi_hash(seed * 4.0) - 1.0; + varColor.a = clamp(varColor.a + alphaSpread * particle.color.spread.a, 0.0, 1.0); // anchor point in eye space float radius = interpolate3Points(particle.radius.start, particle.radius.middle, particle.radius.finish, age); + float radiusSpread = 2.0 * hifi_hash(seed * 5.0) - 1.0; + radius = max(radius + radiusSpread * particle.radius.spread, 0.0); vec4 quadPos = radius * UNIT_QUAD[twoTriID]; vec4 anchorPoint; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index e5ec0223e6..9a7edec88f 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -2937,6 +2937,7 @@ void EntityItemProperties::markAllChanged() { _shapeTypeChanged = true; _isEmittingChanged = true; + _emitterShouldTrail = true; _maxParticlesChanged = true; _lifespanChanged = true; _emitRateChanged = true; diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 92bd86db92..588d09ca14 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -168,13 +168,13 @@ void ParticleEffectEntityItem::setAlpha(float alpha) { void ParticleEffectEntityItem::setAlphaStart(float alphaStart) { withWriteLock([&] { - _particleProperties.alpha.range.start = isnan(alphaStart) ? alphaStart : glm::clamp(alphaStart, MINIMUM_ALPHA, MAXIMUM_ALPHA); + _particleProperties.alpha.range.start = glm::isnan(alphaStart) ? alphaStart : glm::clamp(alphaStart, MINIMUM_ALPHA, MAXIMUM_ALPHA); }); } void ParticleEffectEntityItem::setAlphaFinish(float alphaFinish) { withWriteLock([&] { - _particleProperties.alpha.range.finish = isnan(alphaFinish) ? alphaFinish : glm::clamp(alphaFinish, MINIMUM_ALPHA, MAXIMUM_ALPHA); + _particleProperties.alpha.range.finish = glm::isnan(alphaFinish) ? alphaFinish : glm::clamp(alphaFinish, MINIMUM_ALPHA, MAXIMUM_ALPHA); }); } @@ -292,13 +292,13 @@ void ParticleEffectEntityItem::setParticleRadius(float particleRadius) { void ParticleEffectEntityItem::setRadiusStart(float radiusStart) { withWriteLock([&] { - _particleProperties.radius.range.start = isnan(radiusStart) ? radiusStart : glm::clamp(radiusStart, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); + _particleProperties.radius.range.start = glm::isnan(radiusStart) ? radiusStart : glm::clamp(radiusStart, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); }); } void ParticleEffectEntityItem::setRadiusFinish(float radiusFinish) { withWriteLock([&] { - _particleProperties.radius.range.finish = isnan(radiusFinish) ? radiusFinish : glm::clamp(radiusFinish, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); + _particleProperties.radius.range.finish = glm::isnan(radiusFinish) ? radiusFinish : glm::clamp(radiusFinish, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); }); } diff --git a/libraries/entities/src/ParticleEffectEntityItem.h b/libraries/entities/src/ParticleEffectEntityItem.h index 16621d307d..cd8a19bee5 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.h +++ b/libraries/entities/src/ParticleEffectEntityItem.h @@ -21,10 +21,10 @@ namespace particle { static const float SCRIPT_MAXIMUM_PI = 3.1416f; // Round up so that reasonable property values work static const float UNINITIALIZED = NAN; static const vec3 DEFAULT_COLOR = { 255, 255, 255 }; - static const xColor DEFAULT_XCOLOR = { DEFAULT_COLOR.r, DEFAULT_COLOR.g, DEFAULT_COLOR.b }; + static const xColor DEFAULT_XCOLOR = { (unsigned int)DEFAULT_COLOR.r, (unsigned int)DEFAULT_COLOR.g, (unsigned int)DEFAULT_COLOR.b }; static const vec3 DEFAULT_COLOR_UNINITIALIZED = { UNINITIALIZED, UNINITIALIZED, UNINITIALIZED }; static const vec3 DEFAULT_COLOR_SPREAD = { 0, 0, 0 }; - static const xColor DEFAULT_XCOLOR_SPREAD = { DEFAULT_COLOR_SPREAD.r, DEFAULT_COLOR_SPREAD.g, DEFAULT_COLOR_SPREAD.b }; + static const xColor DEFAULT_XCOLOR_SPREAD = { (unsigned int)DEFAULT_COLOR_SPREAD.r, (unsigned int)DEFAULT_COLOR_SPREAD.g, (unsigned int)DEFAULT_COLOR_SPREAD.b }; static const float DEFAULT_ALPHA = 1.0f; static const float DEFAULT_ALPHA_SPREAD = 0.0f; static const float DEFAULT_ALPHA_START = UNINITIALIZED; @@ -226,10 +226,10 @@ public: void setColor(const xColor& value); void setColorStart(const vec3& colorStart); - vec3 getColorStart() const { return any(isnan(_particleProperties.color.range.start)) ? getColor() : _particleProperties.color.range.start; } + vec3 getColorStart() const { return glm::any(glm::isnan(_particleProperties.color.range.start)) ? getColor() : _particleProperties.color.range.start; } void setColorFinish(const vec3& colorFinish); - vec3 getColorFinish() const { return any(isnan(_particleProperties.color.range.finish)) ? getColor() : _particleProperties.color.range.finish; } + vec3 getColorFinish() const { return glm::any(glm::isnan(_particleProperties.color.range.finish)) ? getColor() : _particleProperties.color.range.finish; } void setColorSpread(const xColor& colorSpread); xColor getColorSpread() const; @@ -238,10 +238,10 @@ public: float getAlpha() const { return _particleProperties.alpha.gradient.target; } void setAlphaStart(float alphaStart); - float getAlphaStart() const { return isnan(_particleProperties.alpha.range.start) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.start; } + float getAlphaStart() const { return glm::isnan(_particleProperties.alpha.range.start) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.start; } void setAlphaFinish(float alphaFinish); - float getAlphaFinish() const { return isnan(_particleProperties.alpha.range.finish) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.finish; } + float getAlphaFinish() const { return glm::isnan(_particleProperties.alpha.range.finish) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.finish; } void setAlphaSpread(float alphaSpread); float getAlphaSpread() const { return _particleProperties.alpha.gradient.spread; } @@ -300,10 +300,10 @@ public: float getParticleRadius() const { return _particleProperties.radius.gradient.target; } void setRadiusStart(float radiusStart); - float getRadiusStart() const { return isnan(_particleProperties.radius.range.start) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.start; } + float getRadiusStart() const { return glm::isnan(_particleProperties.radius.range.start) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.start; } void setRadiusFinish(float radiusFinish); - float getRadiusFinish() const { return isnan(_particleProperties.radius.range.finish) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.finish; } + float getRadiusFinish() const { return glm::isnan(_particleProperties.radius.range.finish) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.finish; } void setRadiusSpread(float radiusSpread); float getRadiusSpread() const { return _particleProperties.radius.gradient.spread; } @@ -311,7 +311,7 @@ public: void computeAndUpdateDimensions(); void setTextures(const QString& textures); - QString ParticleEffectEntityItem::getTextures() const { return _particleProperties.textures; } + QString getTextures() const { return _particleProperties.textures; } bool getEmitterShouldTrail() const { return _particleProperties.emission.shouldTrail; } void setEmitterShouldTrail(bool emitterShouldTrail); diff --git a/libraries/gpu/src/gpu/Noise.slh b/libraries/gpu/src/gpu/Noise.slh new file mode 100644 index 0000000000..b390945957 --- /dev/null +++ b/libraries/gpu/src/gpu/Noise.slh @@ -0,0 +1,297 @@ + + +// Shader includes portions of webgl-noise: +// Description : Array and textureless GLSL 2D/3D/4D simplex +// noise functions. +// Author : Ian McEwan, Ashima Arts. +// Maintainer : ijm +// Lastmod : 20110822 (ijm) +// License : Copyright (C) 2011 Ashima Arts. All rights reserved. +// Distributed under the MIT License. See LICENSE file. +// https://github.com/ashima/webgl-noise +// + +<@if not NOISE_SLH@> +<@def NOISE_SLH@> + +float mod289(float x) { + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec2 mod289(vec2 x) { + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec3 mod289(vec3 x) { + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +vec4 mod289(vec4 x) { + return x - floor(x * (1.0 / 289.0)) * 289.0; +} + +float permute(float x) { + return mod289(((x*34.0)+1.0)*x); +} + +vec3 permute(vec3 x) { + return mod289(((x*34.0)+1.0)*x); +} + +vec4 permute(vec4 x) { + return mod289(((x*34.0)+1.0)*x); +} + +float taylorInvSqrt(float r) { + return 1.79284291400159 - 0.85373472095314 * r; +} + +vec4 taylorInvSqrt(vec4 r) { + return 1.79284291400159 - 0.85373472095314 * r; +} + +vec4 grad4(float j, vec4 ip) { + const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0); + vec4 p, s; + + p.xyz = floor(fract(vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0; + p.w = 1.5 - dot(abs(p.xyz), ones.xyz); + s = vec4(lessThan(p, vec4(0.0))); + p.xyz = p.xyz + (s.xyz * 2.0 - 1.0) * s.www; + + return p; +} + +// (sqrt(5) - 1)/4 = F4, used once below +#define F4 0.309016994374947451 + +float snoise(vec4 v) { + const vec4 C = vec4(0.138196601125011, // (5 - sqrt(5))/20 G4 + 0.276393202250021, // 2 * G4 + 0.414589803375032, // 3 * G4 + -0.447213595499958); // -1 + 4 * G4 + + // First corner + vec4 i = floor(v + dot(v, vec4(F4))); + vec4 x0 = v - i + dot(i, C.xxxx); + + // Other corners + + // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) + vec4 i0; + vec3 isX = step(x0.yzw, x0.xxx); + vec3 isYZ = step(x0.zww, x0.yyz); + i0.x = isX.x + isX.y + isX.z; + i0.yzw = 1.0 - isX; + i0.y += isYZ.x + isYZ.y; + i0.zw += 1.0 - isYZ.xy; + i0.z += isYZ.z; + i0.w += 1.0 - isYZ.z; + + // i0 now contains the unique values 0,1,2,3 in each channel + vec4 i3 = clamp(i0, 0.0, 1.0); + vec4 i2 = clamp(i0 - 1.0, 0.0, 1.0); + vec4 i1 = clamp(i0 - 2.0, 0.0, 1.0); + + vec4 x1 = x0 - i1 + C.xxxx; + vec4 x2 = x0 - i2 + C.yyyy; + vec4 x3 = x0 - i3 + C.zzzz; + vec4 x4 = x0 + C.wwww; + + // Permutations + i = mod289(i); + float j0 = permute(permute(permute(permute(i.w) + i.z) + i.y) + i.x); + vec4 j1 = permute( + permute( + permute( + permute(i.w + vec4(i1.w, i2.w, i3.w, 1.0)) + i.z + + vec4(i1.z, i2.z, i3.z, 1.0)) + i.y + + vec4(i1.y, i2.y, i3.y, 1.0)) + i.x + + vec4(i1.x, i2.x, i3.x, 1.0)); + + // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope + // 7*7*6 = 294, which is close to the ring size 17*17 = 289. + vec4 ip = vec4(1.0 / 294.0, 1.0 / 49.0, 1.0 / 7.0, 0.0); + + vec4 p0 = grad4(j0, ip); + vec4 p1 = grad4(j1.x, ip); + vec4 p2 = grad4(j1.y, ip); + vec4 p3 = grad4(j1.z, ip); + vec4 p4 = grad4(j1.w, ip); + + // Normalise gradients + vec4 norm = taylorInvSqrt( + vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + p4 *= taylorInvSqrt(dot(p4, p4)); + + // Mix contributions from the five corners + vec3 m0 = max(0.6 - vec3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0); + vec2 m1 = max(0.6 - vec2(dot(x3, x3), dot(x4, x4)), 0.0); + m0 = m0 * m0; + m1 = m1 * m1; + return 49.0 + * (dot(m0 * m0, vec3(dot(p0, x0), dot(p1, x1), dot(p2, x2))) + + dot(m1 * m1, vec2(dot(p3, x3), dot(p4, x4)))); + +} + +float snoise(vec3 v) { + const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0); + const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); + + // First corner + vec3 i = floor(v + dot(v, C.yyy)); + vec3 x0 = v - i + dot(i, C.xxx); + + // Other corners + vec3 g = step(x0.yzx, x0.xyz); + vec3 l = 1.0 - g; + vec3 i1 = min(g.xyz, l.zxy); + vec3 i2 = max(g.xyz, l.zxy); + + vec3 x1 = x0 - i1 + C.xxx; + vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y + vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y + + // Permutations + i = mod289(i); + vec4 p = permute( + permute( + permute(i.z + vec4(0.0, i1.z, i2.z, 1.0)) + i.y + + vec4(0.0, i1.y, i2.y, 1.0)) + i.x + + vec4(0.0, i1.x, i2.x, 1.0)); + + // Gradients: 7x7 points over a square, mapped onto an octahedron. + // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) + float n_ = 0.142857142857; // 1.0/7.0 + vec3 ns = n_ * D.wyz - D.xzx; + + vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) + + vec4 x_ = floor(j * ns.z); + vec4 y_ = floor(j - 7.0 * x_); // mod(j,N) + + vec4 x = x_ * ns.x + ns.yyyy; + vec4 y = y_ * ns.x + ns.yyyy; + vec4 h = 1.0 - abs(x) - abs(y); + + vec4 b0 = vec4(x.xy, y.xy); + vec4 b1 = vec4(x.zw, y.zw); + + //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; + //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; + vec4 s0 = floor(b0) * 2.0 + 1.0; + vec4 s1 = floor(b1) * 2.0 + 1.0; + vec4 sh = -step(h, vec4(0.0)); + + vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; + vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; + + vec3 p0 = vec3(a0.xy, h.x); + vec3 p1 = vec3(a0.zw, h.y); + vec3 p2 = vec3(a1.xy, h.z); + vec3 p3 = vec3(a1.zw, h.w); + + //Normalise gradients + vec4 norm = taylorInvSqrt( + vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); + p0 *= norm.x; + p1 *= norm.y; + p2 *= norm.z; + p3 *= norm.w; + + // Mix final noise value + vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), + 0.0); + m = m * m; + return 42.0 + * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); +} + +float snoise(vec2 v) { + const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 + 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) + -0.577350269189626, // -1.0 + 2.0 * C.x + 0.024390243902439); // 1.0 / 41.0 + // First corner + vec2 i = floor(v + dot(v, C.yy)); + vec2 x0 = v - i + dot(i, C.xx); + + // Other corners + vec2 i1; + i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); + vec4 x12 = x0.xyxy + C.xxzz; + x12.xy -= i1; + + // Permutations + i = mod289(i); // Avoid truncation effects in permutation + vec3 p = permute( + permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0)); + + vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), + 0.0); + m = m * m; + m = m * m; + + // Gradients: 41 points uniformly over a line, mapped onto a diamond. + // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) + + vec3 x = 2.0 * fract(p * C.www) - 1.0; + vec3 h = abs(x) - 0.5; + vec3 ox = floor(x + 0.5); + vec3 a0 = x - ox; + + // Normalise gradients implicitly by scaling m + // Approximation of: m *= inversesqrt( a0*a0 + h*h ); + m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h); + + // Compute final noise value at P + vec3 g; + g.x = a0.x * x0.x + h.x * x0.y; + g.yz = a0.yz * x12.xz + h.yz * x12.yw; + return 130.0 * dot(m, g); +} + +// https://www.shadertoy.com/view/lsfGRr +float hifi_hash(float n) { + return fract(sin(n) * 43758.5453); +} + +float hifi_noise(in vec2 x) { + vec2 p = floor(x); + vec2 f = fract(x); + + f = f * f * (3.0 - 2.0 * f); + + float n = p.x + p.y * 57.0; + + return mix(mix(hifi_hash(n + 0.0), hifi_hash(n + 1.0), f.x), + mix(hifi_hash(n + 57.0), hifi_hash(n + 58.0), f.x), f.y); +} + +// https://www.shadertoy.com/view/MdX3Rr +// https://en.wikipedia.org/wiki/Fractional_Brownian_motion +float hifi_fbm(in vec2 p) { + const mat2 m2 = mat2(0.8, -0.6, 0.6, 0.8); + float f = 0.0; + f += 0.5000 * hifi_noise(p); p = m2 * p * 2.02; + f += 0.2500 * hifi_noise(p); p = m2 * p * 2.03; + f += 0.1250 * hifi_noise(p); p = m2 * p * 2.01; + f += 0.0625 * hifi_noise(p); + + return f / 0.9375; +} + +<@endif@> \ No newline at end of file diff --git a/libraries/procedural/src/procedural/ProceduralCommon.slf b/libraries/procedural/src/procedural/ProceduralCommon.slf index dcc34b5131..de226e6dae 100644 --- a/libraries/procedural/src/procedural/ProceduralCommon.slf +++ b/libraries/procedural/src/procedural/ProceduralCommon.slf @@ -8,292 +8,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Shader includes portions of webgl-noise: -// Description : Array and textureless GLSL 2D/3D/4D simplex -// noise functions. -// Author : Ian McEwan, Ashima Arts. -// Maintainer : ijm -// Lastmod : 20110822 (ijm) -// License : Copyright (C) 2011 Ashima Arts. All rights reserved. -// Distributed under the MIT License. See LICENSE file. -// https://github.com/ashima/webgl-noise -// - <@include gpu/Transform.slh@> +<@include gpu/Noise.slh@> + <$declareStandardCameraTransform()$> -float mod289(float x) { - return x - floor(x * (1.0 / 289.0)) * 289.0; -} - -vec2 mod289(vec2 x) { - return x - floor(x * (1.0 / 289.0)) * 289.0; -} - -vec3 mod289(vec3 x) { - return x - floor(x * (1.0 / 289.0)) * 289.0; -} - -vec4 mod289(vec4 x) { - return x - floor(x * (1.0 / 289.0)) * 289.0; -} - -float permute(float x) { - return mod289(((x*34.0)+1.0)*x); -} - -vec3 permute(vec3 x) { - return mod289(((x*34.0)+1.0)*x); -} - -vec4 permute(vec4 x) { - return mod289(((x*34.0)+1.0)*x); -} - -float taylorInvSqrt(float r) { - return 1.79284291400159 - 0.85373472095314 * r; -} - -vec4 taylorInvSqrt(vec4 r) { - return 1.79284291400159 - 0.85373472095314 * r; -} - -vec4 grad4(float j, vec4 ip) { - const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0); - vec4 p, s; - - p.xyz = floor(fract(vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0; - p.w = 1.5 - dot(abs(p.xyz), ones.xyz); - s = vec4(lessThan(p, vec4(0.0))); - p.xyz = p.xyz + (s.xyz * 2.0 - 1.0) * s.www; - - return p; -} - -// (sqrt(5) - 1)/4 = F4, used once below -#define F4 0.309016994374947451 - -float snoise(vec4 v) { - const vec4 C = vec4(0.138196601125011, // (5 - sqrt(5))/20 G4 - 0.276393202250021, // 2 * G4 - 0.414589803375032, // 3 * G4 - -0.447213595499958); // -1 + 4 * G4 - - // First corner - vec4 i = floor(v + dot(v, vec4(F4))); - vec4 x0 = v - i + dot(i, C.xxxx); - - // Other corners - - // Rank sorting originally contributed by Bill Licea-Kane, AMD (formerly ATI) - vec4 i0; - vec3 isX = step(x0.yzw, x0.xxx); - vec3 isYZ = step(x0.zww, x0.yyz); - i0.x = isX.x + isX.y + isX.z; - i0.yzw = 1.0 - isX; - i0.y += isYZ.x + isYZ.y; - i0.zw += 1.0 - isYZ.xy; - i0.z += isYZ.z; - i0.w += 1.0 - isYZ.z; - - // i0 now contains the unique values 0,1,2,3 in each channel - vec4 i3 = clamp(i0, 0.0, 1.0); - vec4 i2 = clamp(i0 - 1.0, 0.0, 1.0); - vec4 i1 = clamp(i0 - 2.0, 0.0, 1.0); - - vec4 x1 = x0 - i1 + C.xxxx; - vec4 x2 = x0 - i2 + C.yyyy; - vec4 x3 = x0 - i3 + C.zzzz; - vec4 x4 = x0 + C.wwww; - - // Permutations - i = mod289(i); - float j0 = permute(permute(permute(permute(i.w) + i.z) + i.y) + i.x); - vec4 j1 = permute( - permute( - permute( - permute(i.w + vec4(i1.w, i2.w, i3.w, 1.0)) + i.z - + vec4(i1.z, i2.z, i3.z, 1.0)) + i.y - + vec4(i1.y, i2.y, i3.y, 1.0)) + i.x - + vec4(i1.x, i2.x, i3.x, 1.0)); - - // Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope - // 7*7*6 = 294, which is close to the ring size 17*17 = 289. - vec4 ip = vec4(1.0 / 294.0, 1.0 / 49.0, 1.0 / 7.0, 0.0); - - vec4 p0 = grad4(j0, ip); - vec4 p1 = grad4(j1.x, ip); - vec4 p2 = grad4(j1.y, ip); - vec4 p3 = grad4(j1.z, ip); - vec4 p4 = grad4(j1.w, ip); - - // Normalise gradients - vec4 norm = taylorInvSqrt( - vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - p4 *= taylorInvSqrt(dot(p4, p4)); - - // Mix contributions from the five corners - vec3 m0 = max(0.6 - vec3(dot(x0, x0), dot(x1, x1), dot(x2, x2)), 0.0); - vec2 m1 = max(0.6 - vec2(dot(x3, x3), dot(x4, x4)), 0.0); - m0 = m0 * m0; - m1 = m1 * m1; - return 49.0 - * (dot(m0 * m0, vec3(dot(p0, x0), dot(p1, x1), dot(p2, x2))) - + dot(m1 * m1, vec2(dot(p3, x3), dot(p4, x4)))); - -} - -float snoise(vec3 v) { - const vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0); - const vec4 D = vec4(0.0, 0.5, 1.0, 2.0); - - // First corner - vec3 i = floor(v + dot(v, C.yyy)); - vec3 x0 = v - i + dot(i, C.xxx); - - // Other corners - vec3 g = step(x0.yzx, x0.xyz); - vec3 l = 1.0 - g; - vec3 i1 = min(g.xyz, l.zxy); - vec3 i2 = max(g.xyz, l.zxy); - - vec3 x1 = x0 - i1 + C.xxx; - vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y - vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y - - // Permutations - i = mod289(i); - vec4 p = permute( - permute( - permute(i.z + vec4(0.0, i1.z, i2.z, 1.0)) + i.y - + vec4(0.0, i1.y, i2.y, 1.0)) + i.x - + vec4(0.0, i1.x, i2.x, 1.0)); - - // Gradients: 7x7 points over a square, mapped onto an octahedron. - // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294) - float n_ = 0.142857142857; // 1.0/7.0 - vec3 ns = n_ * D.wyz - D.xzx; - - vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7) - - vec4 x_ = floor(j * ns.z); - vec4 y_ = floor(j - 7.0 * x_); // mod(j,N) - - vec4 x = x_ * ns.x + ns.yyyy; - vec4 y = y_ * ns.x + ns.yyyy; - vec4 h = 1.0 - abs(x) - abs(y); - - vec4 b0 = vec4(x.xy, y.xy); - vec4 b1 = vec4(x.zw, y.zw); - - //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0; - //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0; - vec4 s0 = floor(b0) * 2.0 + 1.0; - vec4 s1 = floor(b1) * 2.0 + 1.0; - vec4 sh = -step(h, vec4(0.0)); - - vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy; - vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww; - - vec3 p0 = vec3(a0.xy, h.x); - vec3 p1 = vec3(a0.zw, h.y); - vec3 p2 = vec3(a1.xy, h.z); - vec3 p3 = vec3(a1.zw, h.w); - - //Normalise gradients - vec4 norm = taylorInvSqrt( - vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3))); - p0 *= norm.x; - p1 *= norm.y; - p2 *= norm.z; - p3 *= norm.w; - - // Mix final noise value - vec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), - 0.0); - m = m * m; - return 42.0 - * dot(m * m, vec4(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3))); -} - -float snoise(vec2 v) { - const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0 - 0.366025403784439, // 0.5*(sqrt(3.0)-1.0) - -0.577350269189626, // -1.0 + 2.0 * C.x - 0.024390243902439); // 1.0 / 41.0 - // First corner - vec2 i = floor(v + dot(v, C.yy)); - vec2 x0 = v - i + dot(i, C.xx); - - // Other corners - vec2 i1; - i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); - vec4 x12 = x0.xyxy + C.xxzz; - x12.xy -= i1; - - // Permutations - i = mod289(i); // Avoid truncation effects in permutation - vec3 p = permute( - permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0)); - - vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), - 0.0); - m = m * m; - m = m * m; - - // Gradients: 41 points uniformly over a line, mapped onto a diamond. - // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287) - - vec3 x = 2.0 * fract(p * C.www) - 1.0; - vec3 h = abs(x) - 0.5; - vec3 ox = floor(x + 0.5); - vec3 a0 = x - ox; - - // Normalise gradients implicitly by scaling m - // Approximation of: m *= inversesqrt( a0*a0 + h*h ); - m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h); - - // Compute final noise value at P - vec3 g; - g.x = a0.x * x0.x + h.x * x0.y; - g.yz = a0.yz * x12.xz + h.yz * x12.yw; - return 130.0 * dot(m, g); -} - -// https://www.shadertoy.com/view/lsfGRr -float hifi_hash(float n) { - return fract(sin(n) * 43758.5453); -} - -float hifi_noise(in vec2 x) { - vec2 p = floor(x); - vec2 f = fract(x); - - f = f * f * (3.0 - 2.0 * f); - - float n = p.x + p.y * 57.0; - - return mix(mix(hifi_hash(n + 0.0), hifi_hash(n + 1.0), f.x), - mix(hifi_hash(n + 57.0), hifi_hash(n + 58.0), f.x), f.y); -} - -// https://www.shadertoy.com/view/MdX3Rr -// https://en.wikipedia.org/wiki/Fractional_Brownian_motion -float hifi_fbm(in vec2 p) { - const mat2 m2 = mat2(0.8, -0.6, 0.6, 0.8); - float f = 0.0; - f += 0.5000 * hifi_noise(p); p = m2 * p * 2.02; - f += 0.2500 * hifi_noise(p); p = m2 * p * 2.03; - f += 0.1250 * hifi_noise(p); p = m2 * p * 2.01; - f += 0.0625 * hifi_noise(p); - - return f / 0.9375; -} - #define PROCEDURAL 1 //PROCEDURAL_VERSION diff --git a/scripts/system/particle_explorer/particleExplorer.js b/scripts/system/particle_explorer/particleExplorer.js index 099c4be9e3..cb2c2f3374 100644 --- a/scripts/system/particle_explorer/particleExplorer.js +++ b/scripts/system/particle_explorer/particleExplorer.js @@ -152,6 +152,12 @@ type: "SliderFloat", max: 5 }, + { + id: "speedSpread", + name: "Speed Spread", + type: "SliderFloat", + max: 5 + }, { type: "Row" }, From 93fe0c60faef58c5579cfd9423d4190c7398fa19 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 18 Jun 2018 11:26:09 -0700 Subject: [PATCH 11/26] correctly update bounding box based on radius and other properties --- .../entities/src/ParticleEffectEntityItem.cpp | 73 +++++++++++++------ 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 588d09ca14..8679c4cf23 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -185,9 +185,13 @@ void ParticleEffectEntityItem::setAlphaSpread(float alphaSpread) { } void ParticleEffectEntityItem::setLifespan(float lifespan) { - withWriteLock([&] { - _particleProperties.lifespan = glm::clamp(lifespan, MINIMUM_LIFESPAN, MAXIMUM_LIFESPAN); - }); + lifespan = glm::clamp(lifespan, MINIMUM_LIFESPAN, MAXIMUM_LIFESPAN); + if (lifespan != _particleProperties.lifespan) { + withWriteLock([&] { + _particleProperties.lifespan = lifespan; + }); + computeAndUpdateDimensions(); + } } void ParticleEffectEntityItem::setEmitRate(float emitRate) { @@ -218,10 +222,12 @@ void ParticleEffectEntityItem::setSpeedSpread(float speedSpread) { void ParticleEffectEntityItem::setEmitOrientation(const glm::quat& emitOrientation_) { auto emitOrientation = glm::normalize(emitOrientation_); - withWriteLock([&] { - _particleProperties.emission.orientation = emitOrientation; - }); - computeAndUpdateDimensions(); + if (emitOrientation != _particleProperties.emission.orientation) { + withWriteLock([&] { + _particleProperties.emission.orientation = emitOrientation; + }); + computeAndUpdateDimensions(); + } } void ParticleEffectEntityItem::setEmitDimensions(const glm::vec3& emitDimensions_) { @@ -285,27 +291,43 @@ void ParticleEffectEntityItem::setAccelerationSpread(const glm::vec3& accelerati } void ParticleEffectEntityItem::setParticleRadius(float particleRadius) { - withWriteLock([&] { - _particleProperties.radius.gradient.target = glm::clamp(particleRadius, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); - }); + particleRadius = glm::clamp(particleRadius, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); + if (particleRadius != _particleProperties.radius.gradient.target) { + withWriteLock([&] { + _particleProperties.radius.gradient.target = particleRadius; + }); + computeAndUpdateDimensions(); + } } void ParticleEffectEntityItem::setRadiusStart(float radiusStart) { - withWriteLock([&] { - _particleProperties.radius.range.start = glm::isnan(radiusStart) ? radiusStart : glm::clamp(radiusStart, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); - }); + radiusStart = glm::isnan(radiusStart) ? radiusStart : glm::clamp(radiusStart, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); + if (radiusStart != _particleProperties.radius.range.start) { + withWriteLock([&] { + _particleProperties.radius.range.start = radiusStart; + }); + computeAndUpdateDimensions(); + } } void ParticleEffectEntityItem::setRadiusFinish(float radiusFinish) { - withWriteLock([&] { - _particleProperties.radius.range.finish = glm::isnan(radiusFinish) ? radiusFinish : glm::clamp(radiusFinish, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); - }); + radiusFinish = glm::isnan(radiusFinish) ? radiusFinish : glm::clamp(radiusFinish, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); + if (radiusFinish != _particleProperties.radius.range.finish) { + withWriteLock([&] { + _particleProperties.radius.range.finish = radiusFinish; + }); + computeAndUpdateDimensions(); + } } -void ParticleEffectEntityItem::setRadiusSpread(float radiusSpread) { - withWriteLock([&] { - _particleProperties.radius.gradient.spread = glm::clamp(radiusSpread, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); - }); +void ParticleEffectEntityItem::setRadiusSpread(float radiusSpread) { + radiusSpread = glm::clamp(radiusSpread, MINIMUM_PARTICLE_RADIUS, MAXIMUM_PARTICLE_RADIUS); + if (radiusSpread != _particleProperties.radius.gradient.spread) { + withWriteLock([&] { + _particleProperties.radius.gradient.spread = radiusSpread; + }); + computeAndUpdateDimensions(); + } } @@ -320,8 +342,15 @@ void ParticleEffectEntityItem::computeAndUpdateDimensions() { glm::vec3 velocity = particleProperties.emission.speed.target * direction; glm::vec3 velocitySpread = particleProperties.emission.speed.spread * direction; glm::vec3 maxVelocity = glm::abs(velocity) + velocitySpread; - glm::vec3 maxAccleration = glm::abs(_acceleration) + particleProperties.emission.acceleration.spread; - glm::vec3 maxDistance = 0.5f * particleProperties.emission.dimensions + time * maxVelocity + (0.5f * time * time) * maxAccleration; + glm::vec3 maxAccleration = particleProperties.emission.acceleration.target + particleProperties.emission.acceleration.spread; + float maxRadius = particleProperties.radius.gradient.target; + if (!glm::isnan(particleProperties.radius.range.start)) { + maxRadius = glm::max(maxRadius, particleProperties.radius.range.start); + } + if (!glm::isnan(particleProperties.radius.range.finish)) { + maxRadius = glm::max(maxRadius, particleProperties.radius.range.finish); + } + glm::vec3 maxDistance = 0.5f * particleProperties.emission.dimensions + time * maxVelocity + (0.5f * time * time) * maxAccleration + vec3(maxRadius + particleProperties.radius.gradient.spread); if (isNaN(maxDistance)) { qCWarning(entities) << "Bad particle data"; return; From 0d34689320f9341850b527bdda3b7fafe9308be1 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 18 Jun 2018 11:41:05 -0700 Subject: [PATCH 12/26] spread variables jsdoc --- libraries/entities/src/EntityItemProperties.cpp | 13 +++++++++---- libraries/entities/src/ParticleEffectEntityItem.h | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 9a7edec88f..48fd2a3bdc 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -854,7 +854,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * default is Earth's gravity value. * @property {vec3} accelerationSpread=0,0,0 - The spread in accelerations that each particle is given. If * emitAccelerations == {x: 0, y: -9.8, z: 0} and accelerationSpread == - * {x: 0, y: 1, z: 0}, each particle will have an acceleration in the range, {x: 0, y: -10.8, z: 0} + * {x: 0, y: 1, z: 0}, each particle will have an acceleration in the range {x: 0, y: -10.8, z: 0} * – {x: 0, y: -8.8, z: 0}. * @property {Vec3} dimensions - The dimensions of the particle effect, i.e., a bounding box containing all the particles * during their lifetimes, assuming that emitterShouldTrail is false. Read-only. @@ -890,19 +890,24 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * particleRadius value is used. * @property {number} radiusFinish=0.025 - The radius of each particle at the end of its life. If not explicitly set, the * particleRadius value is used. - * @property {number} radiusSpread=0 - Currently not used. + * @property {number} radiusSpread=0 - The spread in radius that each particle is given. If particleRadius == 0.5 + * and radiusSpread == 0.25, each particle will have a radius in the range 0.250.75. * @property {Color} color=255,255,255 - The color of each particle at the middle of its life. * @property {Color} colorStart=255,255,255 - The color of each particle at the start of its life. If not explicitly set, the * color value is used. * @property {Color} colorFinish=255,255,255 - The color of each particle at the end of its life. If not explicitly set, the * color value is used. - * @property {Color} colorSpread=0,0,0 - Currently not used. + * @property {Color} colorSpread=0,0,0 - The spread in color that each particle is given. If + * color == {red: 100, green: 100, blue: 100} and colorSpread == + * {red: 10, green: 25, blue: 50}, each particle will have an acceleration in the range {red: 90, green: 75, blue: 50} + * – {red: 110, green: 125, blue: 150}. * @property {number} alpha=1 - The alpha of each particle at the middle of its life. * @property {number} alphaStart=1 - The alpha of each particle at the start of its life. If not explicitly set, the * alpha value is used. * @property {number} alphaFinish=1 - The alpha of each particle at the end of its life. If not explicitly set, the * alpha value is used. - * @property {number} alphaSpread=0 - Currently not used. + * @property {number} alphaSpread=0 - The spread in alpha that each particle is given. If alpha == 0.5 + * and alphaSpread == 0.25, each particle will have an alpha in the range 0.250.75. * * @property {ShapeType} shapeType="none" - Currently not used. Read-only. * diff --git a/libraries/entities/src/ParticleEffectEntityItem.h b/libraries/entities/src/ParticleEffectEntityItem.h index cd8a19bee5..ecbd76193a 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.h +++ b/libraries/entities/src/ParticleEffectEntityItem.h @@ -21,10 +21,10 @@ namespace particle { static const float SCRIPT_MAXIMUM_PI = 3.1416f; // Round up so that reasonable property values work static const float UNINITIALIZED = NAN; static const vec3 DEFAULT_COLOR = { 255, 255, 255 }; - static const xColor DEFAULT_XCOLOR = { (unsigned int)DEFAULT_COLOR.r, (unsigned int)DEFAULT_COLOR.g, (unsigned int)DEFAULT_COLOR.b }; + static const xColor DEFAULT_XCOLOR = { static_cast(DEFAULT_COLOR.r), static_cast(DEFAULT_COLOR.g), static_cast(DEFAULT_COLOR.b) }; static const vec3 DEFAULT_COLOR_UNINITIALIZED = { UNINITIALIZED, UNINITIALIZED, UNINITIALIZED }; static const vec3 DEFAULT_COLOR_SPREAD = { 0, 0, 0 }; - static const xColor DEFAULT_XCOLOR_SPREAD = { (unsigned int)DEFAULT_COLOR_SPREAD.r, (unsigned int)DEFAULT_COLOR_SPREAD.g, (unsigned int)DEFAULT_COLOR_SPREAD.b }; + static const xColor DEFAULT_XCOLOR_SPREAD = { static_cast(DEFAULT_COLOR_SPREAD.r), static_cast(DEFAULT_COLOR_SPREAD.g), static_cast(DEFAULT_COLOR_SPREAD.b) }; static const float DEFAULT_ALPHA = 1.0f; static const float DEFAULT_ALPHA_SPREAD = 0.0f; static const float DEFAULT_ALPHA_START = UNINITIALIZED; From 12a5d8b550d7945364806628e52435b86d11c1eb Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 18 Jun 2018 13:16:33 -0700 Subject: [PATCH 13/26] quiet ubuntu warnings, particle properties show radians --- libraries/entities/src/EntityItemProperties.h | 4 ++-- .../entities/src/ParticleEffectEntityItem.cpp | 4 +++- .../entities/src/ParticleEffectEntityItem.h | 5 +++-- libraries/shared/src/RegisteredMetaTypes.cpp | 21 ++++++++++++++++--- libraries/shared/src/SharedUtil.h | 2 ++ .../particle_explorer/hifi-entity-ui.js | 9 ++++---- 6 files changed, 33 insertions(+), 12 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index a44c718441..a6d0b2f41b 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -134,8 +134,8 @@ public: DEFINE_PROPERTY_REF(PROP_SCRIPT, Script, script, QString, ENTITY_ITEM_DEFAULT_SCRIPT); DEFINE_PROPERTY(PROP_SCRIPT_TIMESTAMP, ScriptTimestamp, scriptTimestamp, quint64, ENTITY_ITEM_DEFAULT_SCRIPT_TIMESTAMP); DEFINE_PROPERTY_REF(PROP_COLLISION_SOUND_URL, CollisionSoundURL, collisionSoundURL, QString, ENTITY_ITEM_DEFAULT_COLLISION_SOUND_URL); - DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor, particle::DEFAULT_XCOLOR); - DEFINE_PROPERTY_REF(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor, particle::DEFAULT_XCOLOR_SPREAD); + DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, xColor, ParticleEffectEntityItem::DEFAULT_XCOLOR); + DEFINE_PROPERTY_REF(PROP_COLOR_SPREAD, ColorSpread, colorSpread, xColor, ParticleEffectEntityItem::DEFAULT_XCOLOR_SPREAD); DEFINE_PROPERTY_REF(PROP_COLOR_START, ColorStart, colorStart, vec3, particle::DEFAULT_COLOR_UNINITIALIZED); DEFINE_PROPERTY_REF(PROP_COLOR_FINISH, ColorFinish, colorFinish, vec3, particle::DEFAULT_COLOR_UNINITIALIZED); DEFINE_PROPERTY(PROP_ALPHA, Alpha, alpha, float, particle::DEFAULT_ALPHA); diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 8679c4cf23..61c56e220b 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -145,6 +145,8 @@ uint64_t Properties::emitIntervalUsecs() const { return 0; } +const xColor ParticleEffectEntityItem::DEFAULT_XCOLOR = xColor(static_cast(DEFAULT_COLOR.r), static_cast(DEFAULT_COLOR.g), static_cast(DEFAULT_COLOR.b)); +const xColor ParticleEffectEntityItem::DEFAULT_XCOLOR_SPREAD = xColor(static_cast(DEFAULT_COLOR_SPREAD.r), static_cast(DEFAULT_COLOR_SPREAD.g), static_cast(DEFAULT_COLOR_SPREAD.b)); EntityItemPointer ParticleEffectEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer entity(new ParticleEffectEntityItem(entityID), [](EntityItem* ptr) { ptr->deleteLater(); }); @@ -342,7 +344,7 @@ void ParticleEffectEntityItem::computeAndUpdateDimensions() { glm::vec3 velocity = particleProperties.emission.speed.target * direction; glm::vec3 velocitySpread = particleProperties.emission.speed.spread * direction; glm::vec3 maxVelocity = glm::abs(velocity) + velocitySpread; - glm::vec3 maxAccleration = particleProperties.emission.acceleration.target + particleProperties.emission.acceleration.spread; + glm::vec3 maxAccleration = glm::abs(particleProperties.emission.acceleration.target) + particleProperties.emission.acceleration.spread; float maxRadius = particleProperties.radius.gradient.target; if (!glm::isnan(particleProperties.radius.range.start)) { maxRadius = glm::max(maxRadius, particleProperties.radius.range.start); diff --git a/libraries/entities/src/ParticleEffectEntityItem.h b/libraries/entities/src/ParticleEffectEntityItem.h index ecbd76193a..31f6d853a7 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.h +++ b/libraries/entities/src/ParticleEffectEntityItem.h @@ -21,10 +21,8 @@ namespace particle { static const float SCRIPT_MAXIMUM_PI = 3.1416f; // Round up so that reasonable property values work static const float UNINITIALIZED = NAN; static const vec3 DEFAULT_COLOR = { 255, 255, 255 }; - static const xColor DEFAULT_XCOLOR = { static_cast(DEFAULT_COLOR.r), static_cast(DEFAULT_COLOR.g), static_cast(DEFAULT_COLOR.b) }; static const vec3 DEFAULT_COLOR_UNINITIALIZED = { UNINITIALIZED, UNINITIALIZED, UNINITIALIZED }; static const vec3 DEFAULT_COLOR_SPREAD = { 0, 0, 0 }; - static const xColor DEFAULT_XCOLOR_SPREAD = { static_cast(DEFAULT_COLOR_SPREAD.r), static_cast(DEFAULT_COLOR_SPREAD.g), static_cast(DEFAULT_COLOR_SPREAD.b) }; static const float DEFAULT_ALPHA = 1.0f; static const float DEFAULT_ALPHA_SPREAD = 0.0f; static const float DEFAULT_ALPHA_START = UNINITIALIZED; @@ -320,6 +318,9 @@ public: particle::Properties getParticleProperties() const; + static const xColor DEFAULT_XCOLOR; + static const xColor DEFAULT_XCOLOR_SPREAD; + protected: particle::Properties _particleProperties; bool _isEmitting { true }; diff --git a/libraries/shared/src/RegisteredMetaTypes.cpp b/libraries/shared/src/RegisteredMetaTypes.cpp index ed2a1d67eb..a9dbe83b06 100644 --- a/libraries/shared/src/RegisteredMetaTypes.cpp +++ b/libraries/shared/src/RegisteredMetaTypes.cpp @@ -127,13 +127,28 @@ QScriptValue vec3toScriptValue(QScriptEngine* engine, const glm::vec3 &vec3) { obj.setProperty("x", vec3.x); obj.setProperty("y", vec3.y); obj.setProperty("z", vec3.z); + obj.setProperty("red", vec3.x); + obj.setProperty("green", vec3.y); + obj.setProperty("blue", vec3.z); return obj; } void vec3FromScriptValue(const QScriptValue &object, glm::vec3 &vec3) { - vec3.x = object.property("x").toVariant().toFloat(); - vec3.y = object.property("y").toVariant().toFloat(); - vec3.z = object.property("z").toVariant().toFloat(); + auto x = object.property("x").toVariant(); + if (!x.isValid()) { + x = object.property("red").toVariant(); + } + auto y = object.property("y").toVariant(); + if (!y.isValid()) { + y = object.property("green").toVariant(); + } + auto z = object.property("z").toVariant(); + if (!z.isValid()) { + z = object.property("blue").toVariant(); + } + vec3.x = x.toFloat(); + vec3.y = y.toFloat(); + vec3.z = z.toFloat(); } QVariant vec3toVariant(const glm::vec3& vec3) { diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index db9fff3e93..3b24110f18 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -92,6 +92,8 @@ inline QDebug& operator<<(QDebug& dbg, const rgbColor& c) { } struct xColor { + xColor() {} + xColor(unsigned char r, unsigned char g, unsigned char b) : red(r), green(g), blue(b) {} unsigned char red; unsigned char green; unsigned char blue; diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 05b6ba6f75..d09bd1f337 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -144,9 +144,10 @@ HifiEntityUI.prototype = { vector.z = z.value; } json[key] = vector; + } else if (el.className.indexOf("radian") !== -1) { + json[key] = document.getElementById(key).value * RADIANS_PER_DEGREE; } else if (el.className.length > 0) { - json[key] = document.getElementById(key) - .value; + json[key] = document.getElementById(key).value; } } @@ -543,12 +544,11 @@ HifiEntityUI.prototype = { slider.setAttribute("step", 1); inputField.oninput = function (event) { - + // TODO: Remove this functionality? Alan finds it confusing if (parseInt(event.target.value) > parseInt(slider.getAttribute("max")) && group.max !== 1) { slider.setAttribute("max", event.target.value); } slider.value = event.target.value; - self.webBridgeSync(group.id, slider.value); }; inputField.onchange = inputField.oninput; @@ -599,6 +599,7 @@ HifiEntityUI.prototype = { slider.setAttribute("step", 0.01); inputField.oninput = function (event) { + // TODO: Remove this functionality? Alan finds it confusing if (parseFloat(event.target.value) > parseFloat(slider.getAttribute("max")) && group.max !== 1) { slider.setAttribute("max", event.target.value); } From de5fcccc7b122dedf7f4b3b707f74da7b6a9fe02 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 19 Jun 2018 14:22:24 -0700 Subject: [PATCH 14/26] proper reporting of nan values in get --- .../entities/src/ParticleEffectEntityItem.cpp | 28 +++++++++++++------ .../entities/src/ParticleEffectEntityItem.h | 12 ++++---- .../particle_explorer/hifi-entity-ui.js | 19 +++++++++++++ 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index 61c56e220b..18cf7c9252 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -667,16 +667,28 @@ void ParticleEffectEntityItem::setEmitterShouldTrail(bool emitterShouldTrail) { particle::Properties ParticleEffectEntityItem::getParticleProperties() const { particle::Properties result; - withReadLock([&] { - result = _particleProperties; + withReadLock([&] { + result = _particleProperties; // Special case the properties that get treated differently if they're unintialized - result.color.range.start = getColorStart(); - result.color.range.finish = getColorFinish(); - result.alpha.range.start = getAlphaStart(); - result.alpha.range.finish = getAlphaFinish(); - result.radius.range.start = getRadiusStart(); - result.radius.range.finish = getRadiusFinish(); + if (glm::any(glm::isnan(result.color.range.start))) { + result.color.range.start = getColor(); + } + if (glm::any(glm::isnan(result.color.range.finish))) { + result.color.range.finish = getColor(); + } + if (glm::isnan(result.alpha.range.start)) { + result.alpha.range.start = getAlpha(); + } + if (glm::isnan(result.alpha.range.finish)) { + result.alpha.range.finish = getAlpha(); + } + if (glm::isnan(result.radius.range.start)) { + result.radius.range.start = getParticleRadius(); + } + if (glm::isnan(result.radius.range.finish)) { + result.radius.range.finish = getParticleRadius(); + } }); if (!result.valid()) { diff --git a/libraries/entities/src/ParticleEffectEntityItem.h b/libraries/entities/src/ParticleEffectEntityItem.h index 31f6d853a7..7e507ab46a 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.h +++ b/libraries/entities/src/ParticleEffectEntityItem.h @@ -224,10 +224,10 @@ public: void setColor(const xColor& value); void setColorStart(const vec3& colorStart); - vec3 getColorStart() const { return glm::any(glm::isnan(_particleProperties.color.range.start)) ? getColor() : _particleProperties.color.range.start; } + vec3 getColorStart() const { return _particleProperties.color.range.start; } void setColorFinish(const vec3& colorFinish); - vec3 getColorFinish() const { return glm::any(glm::isnan(_particleProperties.color.range.finish)) ? getColor() : _particleProperties.color.range.finish; } + vec3 getColorFinish() const { return _particleProperties.color.range.finish; } void setColorSpread(const xColor& colorSpread); xColor getColorSpread() const; @@ -236,10 +236,10 @@ public: float getAlpha() const { return _particleProperties.alpha.gradient.target; } void setAlphaStart(float alphaStart); - float getAlphaStart() const { return glm::isnan(_particleProperties.alpha.range.start) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.start; } + float getAlphaStart() const { return _particleProperties.alpha.range.start; } void setAlphaFinish(float alphaFinish); - float getAlphaFinish() const { return glm::isnan(_particleProperties.alpha.range.finish) ? _particleProperties.alpha.gradient.target : _particleProperties.alpha.range.finish; } + float getAlphaFinish() const { return _particleProperties.alpha.range.finish; } void setAlphaSpread(float alphaSpread); float getAlphaSpread() const { return _particleProperties.alpha.gradient.spread; } @@ -298,10 +298,10 @@ public: float getParticleRadius() const { return _particleProperties.radius.gradient.target; } void setRadiusStart(float radiusStart); - float getRadiusStart() const { return glm::isnan(_particleProperties.radius.range.start) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.start; } + float getRadiusStart() const { return _particleProperties.radius.range.start; } void setRadiusFinish(float radiusFinish); - float getRadiusFinish() const { return glm::isnan(_particleProperties.radius.range.finish) ? _particleProperties.radius.gradient.target : _particleProperties.radius.range.finish; } + float getRadiusFinish() const { return _particleProperties.radius.range.finish; } void setRadiusSpread(float radiusSpread); float getRadiusSpread() const { return _particleProperties.radius.gradient.spread; } diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index d09bd1f337..a04c3a8f5d 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -243,6 +243,25 @@ HifiEntityUI.prototype = { if (data.messageType === 'particle_settings') { // Update settings var currentProperties = data.currentProperties; + // Update uninitialized variables + if (!currentProperties.alphaStart) { + currentProperties.alphaStart = currentProperties.alpha; + } + if (!currentProperties.alphaFinish) { + currentProperties.alphaFinish = currentProperties.alpha; + } + if (!currentProperties.radiusStart) { + currentProperties.radiusStart = currentProperties.particleRadius; + } + if (!currentProperties.radiusFinish) { + currentProperties.radiusFinish = currentProperties.particleRadius; + } + if (!currentProperties.colorStart.red) { + currentProperties.colorStart = currentProperties.color; + } + if (!currentProperties.colorFinish.red) { + currentProperties.colorFinish = currentProperties.color; + } self.fillFields(currentProperties); // Do expected property match with structure; } else if (data.messageType === 'particle_close') { From 2f0877dc0f58599f6dfa3b1ba3f8a08f3371564a Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 19 Jun 2018 16:36:13 -0700 Subject: [PATCH 15/26] debugging js --- .../particle_explorer/hifi-entity-ui.js | 9 +++++---- .../particle_explorer/particleExplorerTool.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index a04c3a8f5d..a9ebaea1c4 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -61,6 +61,7 @@ function HifiEntityUI(parent) { var self = this; this.webBridgeSync = _.debounce(function (id, val) { + console.log(id + " " + val + " " + self.webBridgeSync); if (self.EventBridge) { var sendPackage = {}; sendPackage[id] = val; @@ -256,10 +257,10 @@ HifiEntityUI.prototype = { if (!currentProperties.radiusFinish) { currentProperties.radiusFinish = currentProperties.particleRadius; } - if (!currentProperties.colorStart.red) { + if (!currentProperties.colorStart || !currentProperties.colorStart.red) { currentProperties.colorStart = currentProperties.color; } - if (!currentProperties.colorFinish.red) { + if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { currentProperties.colorFinish = currentProperties.color; } self.fillFields(currentProperties); @@ -573,7 +574,7 @@ HifiEntityUI.prototype = { inputField.onchange = inputField.oninput; slider.oninput = function (event) { inputField.value = event.target.value; - self.webBridgeSync(group.id, slider.value); + self.webBridgeSync(group.id, inputField.value); }; inputField.id = group.id; @@ -598,7 +599,7 @@ HifiEntityUI.prototype = { } else { inputField.value = Math.ceil(event.target.value); } - self.webBridgeSync(group.id, slider.value * RADIANS_PER_DEGREE); + self.webBridgeSync(group.id, inputField.value * RADIANS_PER_DEGREE); }; var degrees = document.createElement("label"); degrees.innerHTML = "°"; diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index de2cb0bd8b..f9f4842411 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -54,11 +54,30 @@ ParticleExplorerTool = function() { Entities.editEntity(that.activeParticleEntity, data.updatedSettings); for (var key in data.updatedSettings) { + print(key + " " + that.activeParticleProperties.hasOwnProperty(key) + " " + data.updatedSettings[key]) if (that.activeParticleProperties.hasOwnProperty(key)) { that.activeParticleProperties[key] = data.updatedSettings[key]; } } + var optionalProps = ["alphaStart", "alphaFinish", "radiusStart", "radiusFinish", "colorStart", "colorFinish"]; + var fallbackProps = ["alpha", "particleRadius", "color"]; + var entityProps = Entities.getEntityProperties(that.activeParticleProperties, optionalProps); + var needsUpdate = false; + for (var i = 0; i < optionalProps.length; i++) { + if (data.updatedSettings[fallbackProps[Math.floor(i / 2)]]) { + var prop = optionalProps[i * 2]; + if (!that.activeParticleProperties[prop] || !that.activeParticleProperties[prop].red) { + that.activeParticleProperties[prop] = entityProps[fallbackProps[Math.floor(i / 2)]]; + needsUpdate = true; + } + } + } + + if (needsUpdate) { + sendActiveParticleProperties(); + } + } else if (data.messageType === "page_loaded") { sendActiveParticleProperties(); } From 8014f61243c4fdaf2a4a3778e788f2bb364b433e Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 19 Jun 2018 17:42:12 -0700 Subject: [PATCH 16/26] loading priorities for avatars and attachments --- interface/src/avatar/MyAvatar.cpp | 1 + libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp | 4 ++++ libraries/avatars-renderer/src/avatars-renderer/Avatar.h | 4 ++++ .../avatars-renderer/src/avatars-renderer/OtherAvatar.cpp | 1 + 4 files changed, 10 insertions(+) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index d57905ee33..b0369303e9 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -121,6 +121,7 @@ MyAvatar::MyAvatar(QThread* thread) : _headData = new MyHead(this); _skeletonModel = std::make_shared(this, nullptr); + _skeletonModel->setLoadingPriority(MYAVATAR_LOADING_PRIORITY); connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished); connect(_skeletonModel.get(), &Model::setURLFinished, this, [this](bool success) { if (success) { diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp index 615f11e897..b8be54b070 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp @@ -49,6 +49,9 @@ const float DISPLAYNAME_FADE_FACTOR = pow(0.01f, 1.0f / DISPLAYNAME_FADE_TIME); const float DISPLAYNAME_ALPHA = 1.0f; const float DISPLAYNAME_BACKGROUND_ALPHA = 0.4f; const glm::vec3 HAND_TO_PALM_OFFSET(0.0f, 0.12f, 0.08f); +const float Avatar::MYAVATAR_LOADING_PRIORITY = (float)M_PI; // Entity priority is computed as atan2(maxDim, distance) which is <= PI / 2 +const float Avatar::OTHERAVATAR_LOADING_PRIORITY = MYAVATAR_LOADING_PRIORITY - EPSILON; +const float Avatar::ATTACHMENT_LOADING_PRIORITY = OTHERAVATAR_LOADING_PRIORITY - EPSILON; namespace render { template <> const ItemKey payloadGetKey(const AvatarSharedPointer& avatar) { @@ -1418,6 +1421,7 @@ void Avatar::setAttachmentData(const QVector& attachmentData) { if (_attachmentModels[i]->getURL() != attachmentData[i].modelURL) { _attachmentModelsTexturesLoaded[i] = false; } + _attachmentModels[i]->setLoadingPriority(ATTACHMENT_LOADING_PRIORITY); _attachmentModels[i]->setURL(attachmentData[i].modelURL); } } diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h index 10c1d9ead2..98246330c4 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h +++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h @@ -540,6 +540,10 @@ protected: AABox _renderBound; bool _isMeshVisible{ true }; bool _needMeshVisibleSwitch{ true }; + + static const float MYAVATAR_LOADING_PRIORITY; + static const float OTHERAVATAR_LOADING_PRIORITY; + static const float ATTACHMENT_LOADING_PRIORITY; }; #endif // hifi_Avatar_h diff --git a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp index 4382216575..7678c03276 100644 --- a/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp +++ b/libraries/avatars-renderer/src/avatars-renderer/OtherAvatar.cpp @@ -12,6 +12,7 @@ OtherAvatar::OtherAvatar(QThread* thread) : Avatar(thread) { // give the pointer to our head to inherited _headData variable from AvatarData _headData = new Head(this); _skeletonModel = std::make_shared(this, nullptr); + _skeletonModel->setLoadingPriority(OTHERAVATAR_LOADING_PRIORITY); connect(_skeletonModel.get(), &Model::setURLFinished, this, &Avatar::setModelURLFinished); connect(_skeletonModel.get(), &Model::rigReady, this, &Avatar::rigReady); connect(_skeletonModel.get(), &Model::rigReset, this, &Avatar::rigReset); From d878ec66e2a7af1f7005e7614ff180491c5feaee Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 00:07:14 +0300 Subject: [PATCH 17/26] Added Lock for not sending settings_update This occurs only when fields are being filled --- scripts/system/particle_explorer/hifi-entity-ui.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index a9ebaea1c4..545a17288b 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -60,9 +60,10 @@ function HifiEntityUI(parent) { this.parent = parent; var self = this; + this.settingsUpdateLock = false; this.webBridgeSync = _.debounce(function (id, val) { console.log(id + " " + val + " " + self.webBridgeSync); - if (self.EventBridge) { + if (self.EventBridge && !self.settingsUpdateLock) { var sendPackage = {}; sendPackage[id] = val; self.submitChanges(sendPackage); @@ -113,7 +114,6 @@ HifiEntityUI.prototype = { var self = this; var json = {}; var keys = Object.keys(self.builtRows); - for (var i = 0; i < keys.length; i++) { var key = keys[i]; var el = self.builtRows[key]; @@ -151,6 +151,7 @@ HifiEntityUI.prototype = { json[key] = document.getElementById(key).value; } } + return json; }, @@ -158,6 +159,7 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); + self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { fields[i].removeAttribute("disabled"); @@ -228,6 +230,8 @@ HifiEntityUI.prototype = { } } } + + self.settingsUpdateLock = false; }, connect: function (EventBridge) { this.EventBridge = EventBridge; From 32982326b1b18c7b8a86783dde2d0342f8ae504c Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 00:08:36 +0300 Subject: [PATCH 18/26] Moved WebBridge sync to oninput: This avoids the settings_update being called only when the image finishes loaded --- scripts/system/particle_explorer/hifi-entity-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 545a17288b..63defea6ea 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -530,13 +530,13 @@ HifiEntityUI.prototype = { textureImage.classList.remove("no-preview"); textureImage.classList.add("no-texture"); } - self.webBridgeSync(group.id, url); }, 250); textureUrl.oninput = function (event) { // Add throttle var url = event.target.value; imageLoad(url); + self.webBridgeSync(group.id, url); }; textureUrl.onchange = textureUrl.oninput; textureImage.appendChild(image); From 903762b122278e56ec247ec21c80b019cb1f08e3 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 00:17:55 +0300 Subject: [PATCH 19/26] Make sure max constraints reset This now occurs when selecting a new entity and having the UI filled again --- .../particle_explorer/hifi-entity-ui.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 63defea6ea..1f2af50ff7 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -151,7 +151,7 @@ HifiEntityUI.prototype = { json[key] = document.getElementById(key).value; } } - + return json; }, @@ -159,12 +159,18 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); + console.log("Locking Settings Update while filling input Fields."); self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { fields[i].removeAttribute("disabled"); + if (fields[i].hasAttribute("data-max")) { + // Reset Max to original max + fields[i].setAttribute("max", fields[i].getAttribute("data-max")); + } } } + if (self.onSelect) { self.onSelect(); } @@ -230,8 +236,11 @@ HifiEntityUI.prototype = { } } } - - self.settingsUpdateLock = false; + // Now unlocking settings Update lock for sending messages on callbacks. + setTimeout(function () { + console.log("Unlocking UI"); + self.settingsUpdateLock = false; + }, 50); }, connect: function (EventBridge) { this.EventBridge = EventBridge; @@ -297,7 +306,7 @@ HifiEntityUI.prototype = { title.innerHTML = section; title.appendChild(dropDown); sectionDivHeader.appendChild(title); - + var collapsed = index !== 0; dropDown.innerHTML = collapsed ? "L" : "M"; @@ -565,6 +574,7 @@ HifiEntityUI.prototype = { slider.setAttribute("min", group.min !== undefined ? group.min : 0); slider.setAttribute("max", group.max !== undefined ? group.max : 10000); + slider.setAttribute("data-max", group.max !== undefined ? group.max : 10000); slider.setAttribute("step", 1); inputField.oninput = function (event) { @@ -620,6 +630,7 @@ HifiEntityUI.prototype = { slider.setAttribute("min", group.min !== undefined ? group.min : 0); slider.setAttribute("max", group.max !== undefined ? group.max : 1); + slider.setAttribute("data-max", group.max !== undefined ? group.max : 1); slider.setAttribute("step", 0.01); inputField.oninput = function (event) { From 55e75298bd88ed54dbdca76236d01bf4cdcee3d6 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 01:24:32 +0300 Subject: [PATCH 20/26] Added Logging --- scripts/system/particle_explorer/hifi-entity-ui.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 1f2af50ff7..6ad3ed011c 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -58,12 +58,12 @@ var roundFloat = function (input, round) { function HifiEntityUI(parent) { this.parent = parent; - + console.log("Creating a new Entity UI instance!"); var self = this; this.settingsUpdateLock = false; this.webBridgeSync = _.debounce(function (id, val) { - console.log(id + " " + val + " " + self.webBridgeSync); if (self.EventBridge && !self.settingsUpdateLock) { + console.log(id + " " + val + " " + self.webBridgeSync); var sendPackage = {}; sendPackage[id] = val; self.submitChanges(sendPackage); @@ -276,6 +276,7 @@ HifiEntityUI.prototype = { if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { currentProperties.colorFinish = currentProperties.color; } + console.log("Got ScriptEvent particle_settings", data); self.fillFields(currentProperties); // Do expected property match with structure; } else if (data.messageType === 'particle_close') { @@ -284,6 +285,7 @@ HifiEntityUI.prototype = { }); }, build: function () { + console.log("Building UI Anew"); var self = this; var sections = Object.keys(this.structure); this.builtRows = {}; From 8f411ad6c8f9a5c88f8577d0d19efdd8b09b7e03 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 20 Jun 2018 16:13:10 -0700 Subject: [PATCH 21/26] CR --- interface/src/avatar/AvatarActionHold.cpp | 4 +- libraries/avatars/src/AvatarData.cpp | 4 +- .../RenderableParticleEffectEntityItem.cpp | 6 +-- .../entities/src/EntityItemProperties.cpp | 54 +++++++++---------- libraries/entities/src/EntityItemProperties.h | 14 ++--- .../entities/src/EntityItemPropertiesMacros.h | 9 ++-- .../entities/src/EntityScriptingInterface.cpp | 6 +-- .../entities/src/KeyLightPropertyGroup.cpp | 4 +- libraries/physics/src/ObjectActionOffset.cpp | 2 +- libraries/physics/src/ObjectActionTractor.cpp | 4 +- .../src/ObjectActionTravelOriented.cpp | 2 +- .../src/ObjectConstraintBallSocket.cpp | 4 +- .../physics/src/ObjectConstraintConeTwist.cpp | 8 +-- .../physics/src/ObjectConstraintHinge.cpp | 8 +-- .../physics/src/ObjectConstraintSlider.cpp | 8 +-- libraries/shared/src/QVariantGLM.cpp | 20 +++---- libraries/shared/src/QVariantGLM.h | 20 +++---- 17 files changed, 87 insertions(+), 90 deletions(-) diff --git a/interface/src/avatar/AvatarActionHold.cpp b/interface/src/avatar/AvatarActionHold.cpp index 9d568e6d73..dbc82fd70e 100644 --- a/interface/src/avatar/AvatarActionHold.cpp +++ b/interface/src/avatar/AvatarActionHold.cpp @@ -440,8 +440,8 @@ QVariantMap AvatarActionHold::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&]{ arguments["holderID"] = _holderID; - arguments["relativePosition"] = glmToQMap(_relativePosition); - arguments["relativeRotation"] = glmToQMap(_relativeRotation); + arguments["relativePosition"] = vec3ToQMap(_relativePosition); + arguments["relativeRotation"] = quatToQMap(_relativeRotation); arguments["timeScale"] = _linearTimeScale; arguments["hand"] = _hand; arguments["kinematic"] = _kinematic; diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index b5186ba8f4..fc72f34304 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -2400,8 +2400,8 @@ QVariant AttachmentData::toVariant() const { QVariantMap result; result["modelUrl"] = modelURL; result["jointName"] = jointName; - result["translation"] = glmToQMap(translation); - result["rotation"] = glmToQMap(glm::degrees(safeEulerAngles(rotation))); + result["translation"] = vec3ToQMap(translation); + result["rotation"] = vec3ToQMap(glm::degrees(safeEulerAngles(rotation))); result["scale"] = scale; result["soft"] = isSoft; return result; diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index 8cbbf76788..2fb4877ed3 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -195,9 +195,9 @@ ParticleEffectEntityRenderer::CpuParticle ParticleEffectEntityRenderer::createPa // - Distribute points relatively evenly over ellipsoid surface // - Distribute points relatively evenly within ellipsoid volume - float elevationMinZ = sin(PI_OVER_TWO - polarFinish); - float elevationMaxZ = sin(PI_OVER_TWO - polarStart); - float elevation = asin(elevationMinZ + (elevationMaxZ - elevationMinZ) * randFloat()); + float elevationMinZ = sinf(PI_OVER_TWO - polarFinish); + float elevationMaxZ = sinf(PI_OVER_TWO - polarStart); + float elevation = asinf(elevationMinZ + (elevationMaxZ - elevationMinZ) * randFloat()); float azimuth; if (azimuthFinish >= azimuthStart) { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 48fd2a3bdc..7f82876557 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1504,13 +1504,13 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool } COPY_PROPERTY_FROM_QSCRIPTVALUE(lastEditedBy, QUuid, setLastEditedBy); - COPY_PROPERTY_FROM_QSCRIPTVALUE(position, glmVec3, setPosition); - COPY_PROPERTY_FROM_QSCRIPTVALUE(dimensions, glmVec3, setDimensions); - COPY_PROPERTY_FROM_QSCRIPTVALUE(rotation, glmQuat, setRotation); + COPY_PROPERTY_FROM_QSCRIPTVALUE(position, vec3, setPosition); + COPY_PROPERTY_FROM_QSCRIPTVALUE(dimensions, vec3, setDimensions); + COPY_PROPERTY_FROM_QSCRIPTVALUE(rotation, quat, setRotation); COPY_PROPERTY_FROM_QSCRIPTVALUE(density, float, setDensity); - COPY_PROPERTY_FROM_QSCRIPTVALUE(velocity, glmVec3, setVelocity); - COPY_PROPERTY_FROM_QSCRIPTVALUE(gravity, glmVec3, setGravity); - COPY_PROPERTY_FROM_QSCRIPTVALUE(acceleration, glmVec3, setAcceleration); + COPY_PROPERTY_FROM_QSCRIPTVALUE(velocity, vec3, setVelocity); + COPY_PROPERTY_FROM_QSCRIPTVALUE(gravity, vec3, setGravity); + COPY_PROPERTY_FROM_QSCRIPTVALUE(acceleration, vec3, setAcceleration); COPY_PROPERTY_FROM_QSCRIPTVALUE(damping, float, setDamping); COPY_PROPERTY_FROM_QSCRIPTVALUE(restitution, float, setRestitution); COPY_PROPERTY_FROM_QSCRIPTVALUE(friction, float, setFriction); @@ -1518,15 +1518,15 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(script, QString, setScript); COPY_PROPERTY_FROM_QSCRIPTVALUE(scriptTimestamp, quint64, setScriptTimestamp); COPY_PROPERTY_FROM_QSCRIPTVALUE(serverScripts, QString, setServerScripts); - COPY_PROPERTY_FROM_QSCRIPTVALUE(registrationPoint, glmVec3, setRegistrationPoint); - COPY_PROPERTY_FROM_QSCRIPTVALUE(angularVelocity, glmVec3, setAngularVelocity); + COPY_PROPERTY_FROM_QSCRIPTVALUE(registrationPoint, vec3, setRegistrationPoint); + COPY_PROPERTY_FROM_QSCRIPTVALUE(angularVelocity, vec3, setAngularVelocity); COPY_PROPERTY_FROM_QSCRIPTVALUE(angularDamping, float, setAngularDamping); COPY_PROPERTY_FROM_QSCRIPTVALUE(visible, bool, setVisible); COPY_PROPERTY_FROM_QSCRIPTVALUE(canCastShadow, bool, setCanCastShadow); COPY_PROPERTY_FROM_QSCRIPTVALUE(color, xColor, setColor); COPY_PROPERTY_FROM_QSCRIPTVALUE(colorSpread, xColor, setColorSpread); - COPY_PROPERTY_FROM_QSCRIPTVALUE(colorStart, glmVec3, setColorStart); - COPY_PROPERTY_FROM_QSCRIPTVALUE(colorFinish, glmVec3, setColorFinish); + COPY_PROPERTY_FROM_QSCRIPTVALUE(colorStart, vec3, setColorStart); + COPY_PROPERTY_FROM_QSCRIPTVALUE(colorFinish, vec3, setColorFinish); COPY_PROPERTY_FROM_QSCRIPTVALUE(alpha, float, setAlpha); COPY_PROPERTY_FROM_QSCRIPTVALUE(alphaSpread, float, setAlphaSpread); COPY_PROPERTY_FROM_QSCRIPTVALUE(alphaStart, float, setAlphaStart); @@ -1560,15 +1560,15 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(emitRate, float, setEmitRate); COPY_PROPERTY_FROM_QSCRIPTVALUE(emitSpeed, float, setEmitSpeed); COPY_PROPERTY_FROM_QSCRIPTVALUE(speedSpread, float, setSpeedSpread); - COPY_PROPERTY_FROM_QSCRIPTVALUE(emitOrientation, glmQuat, setEmitOrientation); - COPY_PROPERTY_FROM_QSCRIPTVALUE(emitDimensions, glmVec3, setEmitDimensions); + COPY_PROPERTY_FROM_QSCRIPTVALUE(emitOrientation, quat, setEmitOrientation); + COPY_PROPERTY_FROM_QSCRIPTVALUE(emitDimensions, vec3, setEmitDimensions); COPY_PROPERTY_FROM_QSCRIPTVALUE(emitRadiusStart, float, setEmitRadiusStart); COPY_PROPERTY_FROM_QSCRIPTVALUE(polarStart, float, setPolarStart); COPY_PROPERTY_FROM_QSCRIPTVALUE(polarFinish, float, setPolarFinish); COPY_PROPERTY_FROM_QSCRIPTVALUE(azimuthStart, float, setAzimuthStart); COPY_PROPERTY_FROM_QSCRIPTVALUE(azimuthFinish, float, setAzimuthFinish); - COPY_PROPERTY_FROM_QSCRIPTVALUE(emitAcceleration, glmVec3, setEmitAcceleration); - COPY_PROPERTY_FROM_QSCRIPTVALUE(accelerationSpread, glmVec3, setAccelerationSpread); + COPY_PROPERTY_FROM_QSCRIPTVALUE(emitAcceleration, vec3, setEmitAcceleration); + COPY_PROPERTY_FROM_QSCRIPTVALUE(accelerationSpread, vec3, setAccelerationSpread); COPY_PROPERTY_FROM_QSCRIPTVALUE(particleRadius, float, setParticleRadius); COPY_PROPERTY_FROM_QSCRIPTVALUE(radiusSpread, float, setRadiusSpread); COPY_PROPERTY_FROM_QSCRIPTVALUE(radiusStart, float, setRadiusStart); @@ -1578,8 +1578,8 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(materialMappingMode, MaterialMappingMode); COPY_PROPERTY_FROM_QSCRIPTVALUE(priority, quint16, setPriority); COPY_PROPERTY_FROM_QSCRIPTVALUE(parentMaterialName, QString, setParentMaterialName); - COPY_PROPERTY_FROM_QSCRIPTVALUE(materialMappingPos, glmVec2, setMaterialMappingPos); - COPY_PROPERTY_FROM_QSCRIPTVALUE(materialMappingScale, glmVec2, setMaterialMappingScale); + COPY_PROPERTY_FROM_QSCRIPTVALUE(materialMappingPos, vec2, setMaterialMappingPos); + COPY_PROPERTY_FROM_QSCRIPTVALUE(materialMappingScale, vec2, setMaterialMappingScale); COPY_PROPERTY_FROM_QSCRIPTVALUE(materialMappingRot, float, setMaterialMappingRot); COPY_PROPERTY_FROM_QSCRIPTVALUE(materialData, QString, setMaterialData); COPY_PROPERTY_FROM_QSCRIPTVALUE(isVisibleInSecondaryCamera, bool, setIsVisibleInSecondaryCamera); @@ -1606,7 +1606,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(skyboxMode, SkyboxMode); COPY_PROPERTY_FROM_QSCRIPTVALUE(sourceUrl, QString, setSourceUrl); - COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelVolumeSize, glmVec3, setVoxelVolumeSize); + COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelVolumeSize, vec3, setVoxelVolumeSize); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelData, QByteArray, setVoxelData); COPY_PROPERTY_FROM_QSCRIPTVALUE(voxelSurfaceStyle, uint16_t, setVoxelSurfaceStyle); COPY_PROPERTY_FROM_QSCRIPTVALUE(lineWidth, float, setLineWidth); @@ -1653,11 +1653,11 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool COPY_PROPERTY_FROM_QSCRIPTVALUE(parentJointIndex, quint16, setParentJointIndex); COPY_PROPERTY_FROM_QSCRIPTVALUE(queryAACube, AACube, setQueryAACube); - COPY_PROPERTY_FROM_QSCRIPTVALUE(localPosition, glmVec3, setLocalPosition); - COPY_PROPERTY_FROM_QSCRIPTVALUE(localRotation, glmQuat, setLocalRotation); - COPY_PROPERTY_FROM_QSCRIPTVALUE(localVelocity, glmVec3, setLocalVelocity); - COPY_PROPERTY_FROM_QSCRIPTVALUE(localAngularVelocity, glmVec3, setLocalAngularVelocity); - COPY_PROPERTY_FROM_QSCRIPTVALUE(localDimensions, glmVec3, setLocalDimensions); + COPY_PROPERTY_FROM_QSCRIPTVALUE(localPosition, vec3, setLocalPosition); + COPY_PROPERTY_FROM_QSCRIPTVALUE(localRotation, quat, setLocalRotation); + COPY_PROPERTY_FROM_QSCRIPTVALUE(localVelocity, vec3, setLocalVelocity); + COPY_PROPERTY_FROM_QSCRIPTVALUE(localAngularVelocity, vec3, setLocalAngularVelocity); + COPY_PROPERTY_FROM_QSCRIPTVALUE(localDimensions, vec3, setLocalDimensions); COPY_PROPERTY_FROM_QSCRIPTVALUE(jointRotationsSet, qVectorBool, setJointRotationsSet); COPY_PROPERTY_FROM_QSCRIPTVALUE(jointRotations, qVectorQuat, setJointRotations); @@ -1957,8 +1957,8 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_MATERIAL_MAPPING_MODE, MaterialMappingMode, materialMappingMode, MaterialMappingMode); ADD_PROPERTY_TO_MAP(PROP_MATERIAL_PRIORITY, Priority, priority, quint16); ADD_PROPERTY_TO_MAP(PROP_PARENT_MATERIAL_NAME, ParentMaterialName, parentMaterialName, QString); - ADD_PROPERTY_TO_MAP(PROP_MATERIAL_MAPPING_POS, MaterialMappingPos, materialMappingPos, glmVec2); - ADD_PROPERTY_TO_MAP(PROP_MATERIAL_MAPPING_SCALE, MaterialMappingScale, materialMappingScale, glmVec2); + ADD_PROPERTY_TO_MAP(PROP_MATERIAL_MAPPING_POS, MaterialMappingPos, materialMappingPos, vec2); + ADD_PROPERTY_TO_MAP(PROP_MATERIAL_MAPPING_SCALE, MaterialMappingScale, materialMappingScale, vec2); ADD_PROPERTY_TO_MAP(PROP_MATERIAL_MAPPING_ROT, MaterialMappingRot, materialMappingRot, float); ADD_PROPERTY_TO_MAP(PROP_MATERIAL_DATA, MaterialData, materialData, QString); @@ -2738,8 +2738,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_MAPPING_MODE, MaterialMappingMode, setMaterialMappingMode); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_PRIORITY, quint16, setPriority); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_PARENT_MATERIAL_NAME, QString, setParentMaterialName); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_MAPPING_POS, glmVec2, setMaterialMappingPos); - READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_MAPPING_SCALE, glmVec2, setMaterialMappingScale); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_MAPPING_POS, vec2, setMaterialMappingPos); + READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_MAPPING_SCALE, vec2, setMaterialMappingScale); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_MAPPING_ROT, float, setMaterialMappingRot); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MATERIAL_DATA, QString, setMaterialData); } @@ -2809,7 +2809,7 @@ QVector EntityItemProperties::unpackStrokeColors(const QByteArray& st float r = (uint8_t)strokeColors[i++] / 255.0f; float g = (uint8_t)strokeColors[i++] / 255.0f; float b = (uint8_t)strokeColors[i++] / 255.0f; - unpackedStrokeColors[j++] = glmVec3(r, g, b); + unpackedStrokeColors[j++] = vec3(r, g, b); } } else { qCDebug(entities) << "WARNING - Expected received size for stroke colors does not match. Expected: " diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index a6d0b2f41b..9c81e922ff 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -228,8 +228,8 @@ public: DEFINE_PROPERTY_REF_ENUM(PROP_MATERIAL_MAPPING_MODE, MaterialMappingMode, materialMappingMode, MaterialMappingMode, UV); DEFINE_PROPERTY_REF(PROP_MATERIAL_PRIORITY, Priority, priority, quint16, 0); DEFINE_PROPERTY_REF(PROP_PARENT_MATERIAL_NAME, ParentMaterialName, parentMaterialName, QString, "0"); - DEFINE_PROPERTY_REF(PROP_MATERIAL_MAPPING_POS, MaterialMappingPos, materialMappingPos, glmVec2, glm::vec2(0, 0)); - DEFINE_PROPERTY_REF(PROP_MATERIAL_MAPPING_SCALE, MaterialMappingScale, materialMappingScale, glmVec2, glm::vec2(1, 1)); + DEFINE_PROPERTY_REF(PROP_MATERIAL_MAPPING_POS, MaterialMappingPos, materialMappingPos, vec2, glm::vec2(0, 0)); + DEFINE_PROPERTY_REF(PROP_MATERIAL_MAPPING_SCALE, MaterialMappingScale, materialMappingScale, vec2, glm::vec2(1, 1)); DEFINE_PROPERTY_REF(PROP_MATERIAL_MAPPING_ROT, MaterialMappingRot, materialMappingRot, float, 0); DEFINE_PROPERTY_REF(PROP_MATERIAL_DATA, MaterialData, materialData, QString, ""); @@ -249,11 +249,11 @@ public: DEFINE_PROPERTY_REF(PROP_STATIC_CERTIFICATE_VERSION, StaticCertificateVersion, staticCertificateVersion, quint32, ENTITY_ITEM_DEFAULT_STATIC_CERTIFICATE_VERSION); // these are used when bouncing location data into and out of scripts - DEFINE_PROPERTY_REF(PROP_LOCAL_POSITION, LocalPosition, localPosition, glmVec3, ENTITY_ITEM_ZERO_VEC3); - DEFINE_PROPERTY_REF(PROP_LOCAL_ROTATION, LocalRotation, localRotation, glmQuat, ENTITY_ITEM_DEFAULT_ROTATION); - DEFINE_PROPERTY_REF(PROP_LOCAL_VELOCITY, LocalVelocity, localVelocity, glmVec3, ENTITY_ITEM_ZERO_VEC3); - DEFINE_PROPERTY_REF(PROP_LOCAL_ANGULAR_VELOCITY, LocalAngularVelocity, localAngularVelocity, glmVec3, ENTITY_ITEM_ZERO_VEC3); - DEFINE_PROPERTY_REF(PROP_LOCAL_DIMENSIONS, LocalDimensions, localDimensions, glmVec3, ENTITY_ITEM_ZERO_VEC3); + DEFINE_PROPERTY_REF(PROP_LOCAL_POSITION, LocalPosition, localPosition, vec3, ENTITY_ITEM_ZERO_VEC3); + DEFINE_PROPERTY_REF(PROP_LOCAL_ROTATION, LocalRotation, localRotation, quat, ENTITY_ITEM_DEFAULT_ROTATION); + DEFINE_PROPERTY_REF(PROP_LOCAL_VELOCITY, LocalVelocity, localVelocity, vec3, ENTITY_ITEM_ZERO_VEC3); + DEFINE_PROPERTY_REF(PROP_LOCAL_ANGULAR_VELOCITY, LocalAngularVelocity, localAngularVelocity, vec3, ENTITY_ITEM_ZERO_VEC3); + DEFINE_PROPERTY_REF(PROP_LOCAL_DIMENSIONS, LocalDimensions, localDimensions, vec3, ENTITY_ITEM_ZERO_VEC3); DEFINE_PROPERTY_REF(PROP_JOINT_ROTATIONS_SET, JointRotationsSet, jointRotationsSet, QVector, QVector()); DEFINE_PROPERTY_REF(PROP_JOINT_ROTATIONS, JointRotations, jointRotations, QVector, QVector()); diff --git a/libraries/entities/src/EntityItemPropertiesMacros.h b/libraries/entities/src/EntityItemPropertiesMacros.h index 482f914602..213460ec50 100644 --- a/libraries/entities/src/EntityItemPropertiesMacros.h +++ b/libraries/entities/src/EntityItemPropertiesMacros.h @@ -185,9 +185,6 @@ inline QScriptValue convertScriptValue(QScriptEngine* e, const AACube& v) { retu properties.setProperty(#P, V); \ } -typedef glm::vec2 glmVec2; -typedef glm::vec3 glmVec3; -typedef glm::quat glmQuat; typedef QVector qVectorVec3; typedef QVector qVectorQuat; typedef QVector qVectorBool; @@ -224,7 +221,7 @@ inline QByteArray QByteArray_convertFromScriptValue(const QScriptValue& v, bool& return QByteArray::fromBase64(b64.toUtf8()); } -inline glmVec2 glmVec2_convertFromScriptValue(const QScriptValue& v, bool& isValid) { +inline glm::vec2 vec2_convertFromScriptValue(const QScriptValue& v, bool& isValid) { isValid = false; /// assume it can't be converted QScriptValue x = v.property("x"); QScriptValue y = v.property("y"); @@ -241,7 +238,7 @@ inline glmVec2 glmVec2_convertFromScriptValue(const QScriptValue& v, bool& isVal return glm::vec2(0); } -inline glmVec3 glmVec3_convertFromScriptValue(const QScriptValue& v, bool& isValid) { +inline glm::vec3 vec3_convertFromScriptValue(const QScriptValue& v, bool& isValid) { isValid = false; /// assume it can't be converted QScriptValue x = v.property("x"); QScriptValue y = v.property("y"); @@ -297,7 +294,7 @@ inline qVectorBool qVectorBool_convertFromScriptValue(const QScriptValue& v, boo return qVectorBoolFromScriptValue(v); } -inline glmQuat glmQuat_convertFromScriptValue(const QScriptValue& v, bool& isValid) { +inline glm::quat quat_convertFromScriptValue(const QScriptValue& v, bool& isValid) { isValid = false; /// assume it can't be converted QScriptValue x = v.property("x"); QScriptValue y = v.property("y"); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 98407a74c6..c54d833745 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -739,15 +739,15 @@ QVector EntityScriptingInterface::findEntitiesInFrustum(QVariantMap frust const QString POSITION_PROPERTY = "position"; bool positionOK = frustum.contains(POSITION_PROPERTY); - glm::vec3 position = positionOK ? qMapToGlmVec3(frustum[POSITION_PROPERTY]) : glm::vec3(); + glm::vec3 position = positionOK ? qMapToVec3(frustum[POSITION_PROPERTY]) : glm::vec3(); const QString ORIENTATION_PROPERTY = "orientation"; bool orientationOK = frustum.contains(ORIENTATION_PROPERTY); - glm::quat orientation = orientationOK ? qMapToGlmQuat(frustum[ORIENTATION_PROPERTY]) : glm::quat(); + glm::quat orientation = orientationOK ? qMapToQuat(frustum[ORIENTATION_PROPERTY]) : glm::quat(); const QString PROJECTION_PROPERTY = "projection"; bool projectionOK = frustum.contains(PROJECTION_PROPERTY); - glm::mat4 projection = projectionOK ? qMapToGlmMat4(frustum[PROJECTION_PROPERTY]) : glm::mat4(); + glm::mat4 projection = projectionOK ? qMapToMat4(frustum[PROJECTION_PROPERTY]) : glm::mat4(); const QString CENTER_RADIUS_PROPERTY = "centerRadius"; bool centerRadiusOK = frustum.contains(CENTER_RADIUS_PROPERTY); diff --git a/libraries/entities/src/KeyLightPropertyGroup.cpp b/libraries/entities/src/KeyLightPropertyGroup.cpp index e0b6ae6e96..67e6f05921 100644 --- a/libraries/entities/src/KeyLightPropertyGroup.cpp +++ b/libraries/entities/src/KeyLightPropertyGroup.cpp @@ -35,13 +35,13 @@ void KeyLightPropertyGroup::copyToScriptValue(const EntityPropertyFlags& desired void KeyLightPropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) { COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, color, xColor, setColor); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, intensity, float, setIntensity); - COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, direction, glmVec3, setDirection); + COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, direction, vec3, setDirection); COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(keyLight, castShadows, bool, setCastShadows); // legacy property support COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightColor, xColor, setColor, getColor); COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightIntensity, float, setIntensity, getIntensity); - COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightDirection, glmVec3, setDirection, getDirection); + COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightDirection, vec3, setDirection, getDirection); COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(keyLightCastShadows, bool, setCastShadows, getCastShadows); } diff --git a/libraries/physics/src/ObjectActionOffset.cpp b/libraries/physics/src/ObjectActionOffset.cpp index 4c2ed35f8e..24f8a1ba8f 100644 --- a/libraries/physics/src/ObjectActionOffset.cpp +++ b/libraries/physics/src/ObjectActionOffset.cpp @@ -157,7 +157,7 @@ bool ObjectActionOffset::updateArguments(QVariantMap arguments) { QVariantMap ObjectActionOffset::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&] { - arguments["pointToOffsetFrom"] = glmToQMap(_pointToOffsetFrom); + arguments["pointToOffsetFrom"] = vec3ToQMap(_pointToOffsetFrom); arguments["linearTimeScale"] = _linearTimeScale; arguments["linearDistance"] = _linearDistance; }); diff --git a/libraries/physics/src/ObjectActionTractor.cpp b/libraries/physics/src/ObjectActionTractor.cpp index 4235bbd616..c5641ad347 100644 --- a/libraries/physics/src/ObjectActionTractor.cpp +++ b/libraries/physics/src/ObjectActionTractor.cpp @@ -333,9 +333,9 @@ QVariantMap ObjectActionTractor::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&] { arguments["linearTimeScale"] = _linearTimeScale; - arguments["targetPosition"] = glmToQMap(_desiredPositionalTarget); + arguments["targetPosition"] = vec3ToQMap(_desiredPositionalTarget); - arguments["targetRotation"] = glmToQMap(_desiredRotationalTarget); + arguments["targetRotation"] = quatToQMap(_desiredRotationalTarget); arguments["angularTimeScale"] = _angularTimeScale; arguments["otherID"] = _otherID; diff --git a/libraries/physics/src/ObjectActionTravelOriented.cpp b/libraries/physics/src/ObjectActionTravelOriented.cpp index c93cce2482..bd32ed13ff 100644 --- a/libraries/physics/src/ObjectActionTravelOriented.cpp +++ b/libraries/physics/src/ObjectActionTravelOriented.cpp @@ -161,7 +161,7 @@ bool ObjectActionTravelOriented::updateArguments(QVariantMap arguments) { QVariantMap ObjectActionTravelOriented::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&] { - arguments["forward"] = glmToQMap(_forward); + arguments["forward"] = vec3ToQMap(_forward); arguments["angularTimeScale"] = _angularTimeScale; }); return arguments; diff --git a/libraries/physics/src/ObjectConstraintBallSocket.cpp b/libraries/physics/src/ObjectConstraintBallSocket.cpp index b7a186e187..ddb0c75ac9 100644 --- a/libraries/physics/src/ObjectConstraintBallSocket.cpp +++ b/libraries/physics/src/ObjectConstraintBallSocket.cpp @@ -193,9 +193,9 @@ bool ObjectConstraintBallSocket::updateArguments(QVariantMap arguments) { QVariantMap ObjectConstraintBallSocket::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&] { - arguments["pivot"] = glmToQMap(_pivotInA); + arguments["pivot"] = vec3ToQMap(_pivotInA); arguments["otherEntityID"] = _otherID; - arguments["otherPivot"] = glmToQMap(_pivotInB); + arguments["otherPivot"] = vec3ToQMap(_pivotInB); }); return arguments; } diff --git a/libraries/physics/src/ObjectConstraintConeTwist.cpp b/libraries/physics/src/ObjectConstraintConeTwist.cpp index e2b86a9e0f..9551532182 100644 --- a/libraries/physics/src/ObjectConstraintConeTwist.cpp +++ b/libraries/physics/src/ObjectConstraintConeTwist.cpp @@ -279,11 +279,11 @@ bool ObjectConstraintConeTwist::updateArguments(QVariantMap arguments) { QVariantMap ObjectConstraintConeTwist::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&] { - arguments["pivot"] = glmToQMap(_pivotInA); - arguments["axis"] = glmToQMap(_axisInA); + arguments["pivot"] = vec3ToQMap(_pivotInA); + arguments["axis"] = vec3ToQMap(_axisInA); arguments["otherEntityID"] = _otherID; - arguments["otherPivot"] = glmToQMap(_pivotInB); - arguments["otherAxis"] = glmToQMap(_axisInB); + arguments["otherPivot"] = vec3ToQMap(_pivotInB); + arguments["otherAxis"] = vec3ToQMap(_axisInB); arguments["swingSpan1"] = _swingSpan1; arguments["swingSpan2"] = _swingSpan2; arguments["twistSpan"] = _twistSpan; diff --git a/libraries/physics/src/ObjectConstraintHinge.cpp b/libraries/physics/src/ObjectConstraintHinge.cpp index 0a01f413dc..67573918cb 100644 --- a/libraries/physics/src/ObjectConstraintHinge.cpp +++ b/libraries/physics/src/ObjectConstraintHinge.cpp @@ -264,11 +264,11 @@ bool ObjectConstraintHinge::updateArguments(QVariantMap arguments) { QVariantMap ObjectConstraintHinge::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&] { - arguments["pivot"] = glmToQMap(_pivotInA); - arguments["axis"] = glmToQMap(_axisInA); + arguments["pivot"] = vec3ToQMap(_pivotInA); + arguments["axis"] = vec3ToQMap(_axisInA); arguments["otherEntityID"] = _otherID; - arguments["otherPivot"] = glmToQMap(_pivotInB); - arguments["otherAxis"] = glmToQMap(_axisInB); + arguments["otherPivot"] = vec3ToQMap(_pivotInB); + arguments["otherAxis"] = vec3ToQMap(_axisInB); arguments["low"] = _low; arguments["high"] = _high; if (_constraint) { diff --git a/libraries/physics/src/ObjectConstraintSlider.cpp b/libraries/physics/src/ObjectConstraintSlider.cpp index 4776e0e4a6..7865e871de 100644 --- a/libraries/physics/src/ObjectConstraintSlider.cpp +++ b/libraries/physics/src/ObjectConstraintSlider.cpp @@ -289,11 +289,11 @@ bool ObjectConstraintSlider::updateArguments(QVariantMap arguments) { QVariantMap ObjectConstraintSlider::getArguments() { QVariantMap arguments = ObjectDynamic::getArguments(); withReadLock([&] { - arguments["point"] = glmToQMap(_pointInA); - arguments["axis"] = glmToQMap(_axisInA); + arguments["point"] = vec3ToQMap(_pointInA); + arguments["axis"] = vec3ToQMap(_axisInA); arguments["otherEntityID"] = _otherID; - arguments["otherPoint"] = glmToQMap(_pointInB); - arguments["otherAxis"] = glmToQMap(_axisInB); + arguments["otherPoint"] = vec3ToQMap(_pointInB); + arguments["otherAxis"] = vec3ToQMap(_axisInB); arguments["linearLow"] = _linearLow; arguments["linearHigh"] = _linearHigh; arguments["angularLow"] = _angularLow; diff --git a/libraries/shared/src/QVariantGLM.cpp b/libraries/shared/src/QVariantGLM.cpp index 1c73315d94..f7fd7fbc8a 100644 --- a/libraries/shared/src/QVariantGLM.cpp +++ b/libraries/shared/src/QVariantGLM.cpp @@ -12,11 +12,11 @@ #include "QVariantGLM.h" #include "OctalCode.h" -QVariantList glmToQList(const glm::vec3& g) { +QVariantList vec3ToQList(const glm::vec3& g) { return QVariantList() << g[0] << g[1] << g[2]; } -QVariantList glmToQList(const glm::quat& g) { +QVariantList quatToQList(const glm::quat& g) { return QVariantList() << g.x << g.y << g.z << g.w; } @@ -24,7 +24,7 @@ QVariantList rgbColorToQList(const rgbColor& v) { return QVariantList() << (int)(v[0]) << (int)(v[1]) << (int)(v[2]); } -QVariantMap glmToQMap(const glm::vec3& glmVector) { +QVariantMap vec3ToQMap(const glm::vec3& glmVector) { QVariantMap vectorAsVariantMap; vectorAsVariantMap["x"] = glmVector.x; vectorAsVariantMap["y"] = glmVector.y; @@ -32,7 +32,7 @@ QVariantMap glmToQMap(const glm::vec3& glmVector) { return vectorAsVariantMap; } -QVariantMap glmToQMap(const glm::quat& glmQuat) { +QVariantMap quatToQMap(const glm::quat& glmQuat) { QVariantMap quatAsVariantMap; quatAsVariantMap["x"] = glmQuat.x; quatAsVariantMap["y"] = glmQuat.y; @@ -42,12 +42,12 @@ QVariantMap glmToQMap(const glm::quat& glmQuat) { } -glm::vec3 qListToGlmVec3(const QVariant& q) { +glm::vec3 qListToVec3(const QVariant& q) { QVariantList qList = q.toList(); return glm::vec3(qList[RED_INDEX].toFloat(), qList[GREEN_INDEX].toFloat(), qList[BLUE_INDEX].toFloat()); } -glm::quat qListToGlmQuat(const QVariant& q) { +glm::quat qListToQuat(const QVariant& q) { QVariantList qList = q.toList(); float x = qList[0].toFloat(); float y = qList[1].toFloat(); @@ -56,7 +56,7 @@ glm::quat qListToGlmQuat(const QVariant& q) { return glm::quat(w, x, y, z); } -void qListtoRgbColor(const QVariant& q, rgbColor& returnValue) { +void qListToRgbColor(const QVariant& q, rgbColor& returnValue) { QVariantList qList = q.toList(); returnValue[RED_INDEX] = qList[RED_INDEX].toInt(); returnValue[GREEN_INDEX] = qList[GREEN_INDEX].toInt(); @@ -64,7 +64,7 @@ void qListtoRgbColor(const QVariant& q, rgbColor& returnValue) { } -glm::vec3 qMapToGlmVec3(const QVariant& q) { +glm::vec3 qMapToVec3(const QVariant& q) { QVariantMap qMap = q.toMap(); if (qMap.contains("x") && qMap.contains("y") && qMap.contains("z")) { return glm::vec3( @@ -77,7 +77,7 @@ glm::vec3 qMapToGlmVec3(const QVariant& q) { } } -glm::quat qMapToGlmQuat(const QVariant& q) { +glm::quat qMapToQuat(const QVariant& q) { QVariantMap qMap = q.toMap(); if (qMap.contains("w") && qMap.contains("x") && qMap.contains("y") && qMap.contains("z")) { return glm::quat( @@ -91,7 +91,7 @@ glm::quat qMapToGlmQuat(const QVariant& q) { } } -glm::mat4 qMapToGlmMat4(const QVariant& q) { +glm::mat4 qMapToMat4(const QVariant& q) { QVariantMap qMap = q.toMap(); if (qMap.contains("r0c0") && qMap.contains("r1c0") && qMap.contains("r2c0") && qMap.contains("r3c0") && qMap.contains("r0c1") && qMap.contains("r1c1") && qMap.contains("r2c1") && qMap.contains("r3c1") diff --git a/libraries/shared/src/QVariantGLM.h b/libraries/shared/src/QVariantGLM.h index 314889d5dd..a8f8b531c0 100644 --- a/libraries/shared/src/QVariantGLM.h +++ b/libraries/shared/src/QVariantGLM.h @@ -17,17 +17,17 @@ #include "SharedUtil.h" -QVariantList glmToQList(const glm::vec3& g); -QVariantList glmToQList(const glm::quat& g); +QVariantList vec3ToQList(const glm::vec3& g); +QVariantList quatToQList(const glm::quat& g); QVariantList rgbColorToQList(const rgbColor& v); -QVariantMap glmToQMap(const glm::vec3& glmVector); -QVariantMap glmToQMap(const glm::quat& glmQuat); +QVariantMap vec3ToQMap(const glm::vec3& glmVector); +QVariantMap quatToQMap(const glm::quat& glmQuat); -glm::vec3 qListToGlmVec3(const QVariant& q); -glm::quat qListToGlmQuat(const QVariant& q); -void qListtoRgbColor(const QVariant& q, rgbColor& returnValue); +glm::vec3 qListToVec3(const QVariant& q); +glm::quat qListToQuat(const QVariant& q); +void qListToRgbColor(const QVariant& q, rgbColor& returnValue); -glm::vec3 qMapToGlmVec3(const QVariant& q); -glm::quat qMapToGlmQuat(const QVariant& q); -glm::mat4 qMapToGlmMat4(const QVariant& q); +glm::vec3 qMapToVec3(const QVariant& q); +glm::quat qMapToQuat(const QVariant& q); +glm::mat4 qMapToMat4(const QVariant& q); From 64fdb8fe62414569c14a334ae145b69ae8f33cc4 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 20 Jun 2018 17:18:12 -0700 Subject: [PATCH 22/26] simplify etc2comp cmake --- cmake/externals/etc2comp/CMakeLists.txt | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cmake/externals/etc2comp/CMakeLists.txt b/cmake/externals/etc2comp/CMakeLists.txt index d8396404dd..b497212625 100644 --- a/cmake/externals/etc2comp/CMakeLists.txt +++ b/cmake/externals/etc2comp/CMakeLists.txt @@ -33,23 +33,20 @@ ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) -if (WIN32) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/build/EtcLib/Debug/EtcLib.lib CACHE FILEPATH "Path to Etc2Comp debug library") +if (WIN32 OR APPLE) + if (WIN32) + set(_LIB_FILE "EtcLib.lib") + else () + set(_LIB_FILE "libEtcLib.a") + endif () + + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/build/EtcLib/Debug/${_LIB_FILE} CACHE FILEPATH "Path to Etc2Comp debug library") # use generator expression to ensure the correct library is found when building different configurations in VS set(_LIB_FOLDER "$<$:build/EtcLib/RelWithDebInfo>") set(_LIB_FOLDER "${_LIB_FOLDER}$<$:build/EtcLib/MinSizeRel>") set(_LIB_FOLDER "${_LIB_FOLDER}$<$,$>:build/EtcLib/Release>") - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/${_LIB_FOLDER}/EtcLib.lib CACHE FILEPATH "Path to Etc2Comp release library") - -elseif (APPLE) - set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/build/EtcLib/Debug/libEtcLib.a CACHE FILEPATH "Path to EtcLib debug library") - - set(_LIB_FOLDER "$<$:build/EtcLib/RelWithDebInfo>") - set(_LIB_FOLDER "${_LIB_FOLDER}$<$:build/EtcLib/MinSizeRel>") - set(_LIB_FOLDER "${_LIB_FOLDER}$<$,$>:build/EtcLib/Release>") - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/${_LIB_FOLDER}/libEtcLib.a CACHE FILEPATH "Path to Etc2Comp release library") - + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/${_LIB_FOLDER}/${_LIB_FILE} CACHE FILEPATH "Path to Etc2Comp release library") else () set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG "" CACHE FILEPATH "Path to EtcLib debug library") set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/build/EtcLib/libEtcLib.a CACHE FILEPATH "Path to EtcLib release library") From 223350b7be507b67365d84e8fa3aca6fac4389cf Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 20 Jun 2018 16:21:29 -0700 Subject: [PATCH 23/26] remove logging, play with debounce times --- .../system/particle_explorer/hifi-entity-ui.js | 16 ++++++---------- .../particle_explorer/particleExplorerTool.js | 10 +++++----- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 6ad3ed011c..36505a0b7f 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -44,6 +44,7 @@ and If there is any changes to either the Entities or properties of **/ var RADIANS_PER_DEGREE = Math.PI / 180; +var DEBOUNCE_TIMEOUT = 125; var roundFloat = function (input, round) { round = round ? round : 1000; @@ -58,17 +59,16 @@ var roundFloat = function (input, round) { function HifiEntityUI(parent) { this.parent = parent; - console.log("Creating a new Entity UI instance!"); + var self = this; this.settingsUpdateLock = false; this.webBridgeSync = _.debounce(function (id, val) { if (self.EventBridge && !self.settingsUpdateLock) { - console.log(id + " " + val + " " + self.webBridgeSync); var sendPackage = {}; sendPackage[id] = val; self.submitChanges(sendPackage); } - }, 125); + }, DEBOUNCE_TIMEOUT); } HifiEntityUI.prototype = { @@ -159,7 +159,6 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); - console.log("Locking Settings Update while filling input Fields."); self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { @@ -238,9 +237,8 @@ HifiEntityUI.prototype = { } // Now unlocking settings Update lock for sending messages on callbacks. setTimeout(function () { - console.log("Unlocking UI"); self.settingsUpdateLock = false; - }, 50); + }, DEBOUNCE_TIMEOUT * 2.5); }, connect: function (EventBridge) { this.EventBridge = EventBridge; @@ -276,7 +274,6 @@ HifiEntityUI.prototype = { if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { currentProperties.colorFinish = currentProperties.color; } - console.log("Got ScriptEvent particle_settings", data); self.fillFields(currentProperties); // Do expected property match with structure; } else if (data.messageType === 'particle_close') { @@ -285,7 +282,6 @@ HifiEntityUI.prototype = { }); }, build: function () { - console.log("Building UI Anew"); var self = this; var sections = Object.keys(this.structure); this.builtRows = {}; @@ -541,7 +537,7 @@ HifiEntityUI.prototype = { textureImage.classList.remove("no-preview"); textureImage.classList.add("no-texture"); } - }, 250); + }, DEBOUNCE_TIMEOUT * 2); textureUrl.oninput = function (event) { // Add throttle @@ -728,4 +724,4 @@ HifiEntityUI.prototype = { } return row; } -}; +}; \ No newline at end of file diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index f9f4842411..a1f06fda35 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -54,7 +54,6 @@ ParticleExplorerTool = function() { Entities.editEntity(that.activeParticleEntity, data.updatedSettings); for (var key in data.updatedSettings) { - print(key + " " + that.activeParticleProperties.hasOwnProperty(key) + " " + data.updatedSettings[key]) if (that.activeParticleProperties.hasOwnProperty(key)) { that.activeParticleProperties[key] = data.updatedSettings[key]; } @@ -65,10 +64,11 @@ ParticleExplorerTool = function() { var entityProps = Entities.getEntityProperties(that.activeParticleProperties, optionalProps); var needsUpdate = false; for (var i = 0; i < optionalProps.length; i++) { - if (data.updatedSettings[fallbackProps[Math.floor(i / 2)]]) { - var prop = optionalProps[i * 2]; - if (!that.activeParticleProperties[prop] || !that.activeParticleProperties[prop].red) { - that.activeParticleProperties[prop] = entityProps[fallbackProps[Math.floor(i / 2)]]; + var fallback = fallbackProps[Math.floor(i / 2)]; + if (data.updatedSettings[fallback]) { + var prop = optionalProps[i]; + if (!that.activeParticleProperties[prop] || (fallback === "color" && !that.activeParticleProperties[prop].red)) { + that.activeParticleProperties[prop] = entityProps[fallback]; needsUpdate = true; } } From d37a8bcd72b26931a5a514700c26f484724cb50a Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Fri, 22 Jun 2018 10:13:18 -0700 Subject: [PATCH 24/26] more jsdoc updates --- libraries/entities/src/EntityItemProperties.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 773ceafa9e..efd2376677 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -886,25 +886,25 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { * @property {string} textures="" - The URL of a JPG or PNG image file to display for each particle. If you want transparency, * use PNG format. * @property {number} particleRadius=0.025 - The radius of each particle at the middle of its life. - * @property {number} radiusStart=0.025 - The radius of each particle at the start of its life. If not explicitly set, the + * @property {number} radiusStart=NAN - The radius of each particle at the start of its life. If NAN, the * particleRadius value is used. - * @property {number} radiusFinish=0.025 - The radius of each particle at the end of its life. If not explicitly set, the + * @property {number} radiusFinish=NAN - The radius of each particle at the end of its life. If NAN, the * particleRadius value is used. * @property {number} radiusSpread=0 - The spread in radius that each particle is given. If particleRadius == 0.5 * and radiusSpread == 0.25, each particle will have a radius in the range 0.250.75. * @property {Color} color=255,255,255 - The color of each particle at the middle of its life. - * @property {Color} colorStart=255,255,255 - The color of each particle at the start of its life. If not explicitly set, the + * @property {Color} colorStart=NAN,NAN,NAN - The color of each particle at the start of its life. If any of the values are NAN, the * color value is used. - * @property {Color} colorFinish=255,255,255 - The color of each particle at the end of its life. If not explicitly set, the + * @property {Color} colorFinish=NAN,NAN,NAN - The color of each particle at the end of its life. If any of the values are NAN, the * color value is used. * @property {Color} colorSpread=0,0,0 - The spread in color that each particle is given. If * color == {red: 100, green: 100, blue: 100} and colorSpread == * {red: 10, green: 25, blue: 50}, each particle will have an acceleration in the range {red: 90, green: 75, blue: 50} * – {red: 110, green: 125, blue: 150}. * @property {number} alpha=1 - The alpha of each particle at the middle of its life. - * @property {number} alphaStart=1 - The alpha of each particle at the start of its life. If not explicitly set, the + * @property {number} alphaStart=NAN - The alpha of each particle at the start of its life. If NAN, the * alpha value is used. - * @property {number} alphaFinish=1 - The alpha of each particle at the end of its life. If not explicitly set, the + * @property {number} alphaFinish=NAN - The alpha of each particle at the end of its life. If NAN, the * alpha value is used. * @property {number} alphaSpread=0 - The spread in alpha that each particle is given. If alpha == 0.5 * and alphaSpread == 0.25, each particle will have an alpha in the range 0.250.75. From 80adad7965101f2ac5148e7c5529728f54e99067 Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 22 Jun 2018 13:52:43 -0700 Subject: [PATCH 25/26] myAvatar constant --- scripts/system/libraries/entitySelectionTool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 8b1c50b129..a5a28fb206 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2028,8 +2028,9 @@ SelectionDisplay = (function() { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED }); } - if (properties.collidesWith.indexOf("myAvatar") > -1) { - var newCollidesWith = properties.collidesWith.replace("myAvatar", ""); + var collisionToRemove = "myAvatar"; + if (properties.collidesWith.indexOf(collisionToRemove) > -1) { + var newCollidesWith = properties.collidesWith.replace(collisionToRemove, ""); Entities.editEntity(SelectionManager.selections[0], {collidesWith: newCollidesWith}); that.replaceCollisionsAfterStretch = true; } From 6fce6431a31fe1aba1f41f4452cda59a9fc6ce46 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Fri, 22 Jun 2018 16:09:49 -0700 Subject: [PATCH 26/26] Fix MS16088: Prevent long usernames from overlapping HFC logo in Wallet Home --- interface/resources/qml/hifi/commerce/wallet/WalletHome.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml index 2a6ddfddfb..354673a3c2 100644 --- a/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml +++ b/interface/resources/qml/hifi/commerce/wallet/WalletHome.qml @@ -76,7 +76,7 @@ Item { anchors.top: parent.top; anchors.left: parent.left; anchors.leftMargin: 20; - width: parent.width/2; + width: parent.width/2 - anchors.leftMargin; height: 80; }