From 02a24712caa119ba7822698d44149e8f10b5f149 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Wed, 7 Oct 2015 19:52:29 -0700 Subject: [PATCH 1/5] fix isEmitting property for particle effects, cleaned up some particle property editing in edit.js --- examples/edit.js | 2 +- examples/html/entityProperties.html | 75 +++++++++---------- .../entities/src/EntityItemProperties.cpp | 4 + 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/examples/edit.js b/examples/edit.js index 0a1f31f0d7..98ad21f4e2 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -1275,7 +1275,7 @@ PropertiesTool = function(opts) { webView.eventBridge.emitScriptEvent(JSON.stringify(data)); }); - webView.eventBridge.webEventReceived.connect(function(data) { + webView.eventBridge.webEventReceived.connect(function (data) { data = JSON.parse(data); if (data.type == "print") { if (data.message) { diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 268e95010c..ac46272a4d 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -305,14 +305,10 @@ var elParticleSections = document.querySelectorAll(".particle-section"); allSections.push(elParticleSections); + var elParticleIsEmitting = document.getElementById("property-particle-is-emitting"); var elParticleMaxParticles = document.getElementById("property-particle-maxparticles"); var elParticleLifeSpan = document.getElementById("property-particle-lifespan"); var elParticleEmitRate = document.getElementById("property-particle-emit-rate"); - var elParticleEmitDirectionX = document.getElementById("property-particle-emit-direction-x"); - var elParticleEmitDirectionY = document.getElementById("property-particle-emit-direction-y"); - var elParticleEmitDirectionZ = document.getElementById("property-particle-emit-direction-z"); - var elParticleEmitStrength = document.getElementById("property-particle-emit-strength"); - var elParticleLocalGravity = document.getElementById("property-particle-localgravity"); var elParticleRadius = document.getElementById("property-particle-radius"); var elTextSections = document.querySelectorAll(".text-section"); @@ -511,7 +507,7 @@ elColorSection.style.display = 'none'; } - if (properties.type == "Model" || properties.type == "ParticleEffect") { + if (properties.type == "Model") { for (var i = 0; i < elModelSections.length; i++) { elModelSections[i].style.display = 'block'; } @@ -617,15 +613,38 @@ elParticleSections[i].style.display = 'block'; } + elParticleIsEmitting.checked = properties.isEmitting; elParticleMaxParticles.value = properties.maxParticles; elParticleLifeSpan.value = properties.lifespan.toFixed(2); elParticleEmitRate.value = properties.emitRate.toFixed(1); - elParticleEmitDirectionX.value = properties.emitDirection.x.toFixed(2); - elParticleEmitDirectionY.value = properties.emitDirection.y.toFixed(2); - elParticleEmitDirectionZ.value = properties.emitDirection.z.toFixed(2); - elParticleEmitStrength.value = properties.emitStrength.toFixed(2); - elParticleLocalGravity.value = properties.localGravity.toFixed(2); elParticleRadius.value = properties.particleRadius.toFixed(3); + + /* + COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(colorSpread, getColorSpread); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(colorStart, getColorStart); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(colorFinish, getColorFinish); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(alphaSpread, getAlphaSpread); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(alphaStart, getAlphaStart); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(alphaFinish, getAlphaFinish); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures); + // float emitSpeed + // float speedSpread + // quat emitOrientation + // vec3 emitDimensions + // float emitRadiusStart + // float polarStart + // float polarFinish + // float azimuthStart + // float azimuthFinish + // vec3 emitAcceleration + // vec3 accelerationSpread + // float radiusStart + // float radiusSpread?? + // float radiusFinish + // float RadiusSpread + */ + } else if (properties.type == "PolyVox") { for (var i = 0; i < elPolyVoxSections.length; i++) { elPolyVoxSections[i].style.display = 'block'; @@ -758,16 +777,10 @@ elWebSourceURL.addEventListener('change', createEmitTextPropertyUpdateFunction('sourceUrl')); + elParticleIsEmitting.addEventListener('change', createEmitCheckedPropertyUpdateFunction('isEmitting')); elParticleMaxParticles.addEventListener('change', createEmitNumberPropertyUpdateFunction('maxParticles')); elParticleLifeSpan.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifespan')); elParticleEmitRate.addEventListener('change', createEmitNumberPropertyUpdateFunction('emitRate')); - var particleEmitDirectionChangeFunction = createEmitVec3PropertyUpdateFunctionWithMultiplier( - 'emitDirection', elParticleEmitDirectionX, elParticleEmitDirectionY, elParticleEmitDirectionZ, DEGREES_TO_RADIANS); - elParticleEmitDirectionX.addEventListener('change', particleEmitDirectionChangeFunction); - elParticleEmitDirectionY.addEventListener('change', particleEmitDirectionChangeFunction); - elParticleEmitDirectionZ.addEventListener('change', particleEmitDirectionChangeFunction); - elParticleEmitStrength.addEventListener('change', createEmitNumberPropertyUpdateFunction('emitStrength')); - elParticleLocalGravity.addEventListener('change', createEmitNumberPropertyUpdateFunction('localGravity')); elParticleRadius.addEventListener('change', createEmitNumberPropertyUpdateFunction('particleRadius')); elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL')); @@ -1362,6 +1375,12 @@ +
+ Is Emitting + + + +
Max Particles
@@ -1380,26 +1399,6 @@
-
-
Particle Emission Direction
-
-
X
-
Y
-
Z
-
-
-
-
Particle Emission Strength
-
- -
-
-
-
Particle Local Gravity
-
- -
-
Particle Radius
diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index b17ca41e9b..62d7e69202 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -313,6 +313,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const { CHECK_PROPERTY_CHANGE(PROP_TEXT_COLOR, textColor); CHECK_PROPERTY_CHANGE(PROP_BACKGROUND_COLOR, backgroundColor); CHECK_PROPERTY_CHANGE(PROP_SHAPE_TYPE, shapeType); + CHECK_PROPERTY_CHANGE(PROP_EMITTING_PARTICLES, isEmitting); CHECK_PROPERTY_CHANGE(PROP_MAX_PARTICLES, maxParticles); CHECK_PROPERTY_CHANGE(PROP_LIFESPAN, lifespan); CHECK_PROPERTY_CHANGE(PROP_EMIT_RATE, emitRate); @@ -424,6 +425,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool // Particles only if (_type == EntityTypes::ParticleEffect) { + COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_EMITTING_PARTICLES, isEmitting); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_PARTICLES, maxParticles); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LIFESPAN, lifespan); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_EMIT_RATE, emitRate); @@ -1118,6 +1120,7 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItem APPEND_ENTITY_PROPERTY(PROP_ACTION_DATA, properties.getActionData()); APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha()); } + if (propertyCount > 0) { int endOfEntityItemData = packetData->getUncompressedByteOffset(); @@ -1472,6 +1475,7 @@ void EntityItemProperties::markAllChanged() { _backgroundColorChanged = true; _shapeTypeChanged = true; + _isEmittingChanged = true; _maxParticlesChanged = true; _lifespanChanged = true; _emitRateChanged = true; From bb10d8a7d5d7deaa6295e5f54016415647076384 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Wed, 7 Oct 2015 20:08:30 -0700 Subject: [PATCH 2/5] more work on rationalizing particle properties --- examples/html/entityProperties.html | 29 ++++++++++++------- .../entities/src/ParticleEffectEntityItem.cpp | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index ac46272a4d..dcb49477d8 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -310,6 +310,7 @@ var elParticleLifeSpan = document.getElementById("property-particle-lifespan"); var elParticleEmitRate = document.getElementById("property-particle-emit-rate"); var elParticleRadius = document.getElementById("property-particle-radius"); + var elParticleTextures = document.getElementById("property-particle-textures"); var elTextSections = document.querySelectorAll(".text-section"); allSections.push(elTextSections); @@ -525,7 +526,7 @@ elModelAnimationHold.checked = properties.animation.hold; elModelAnimationStartAutomatically.checked = properties.animation.startAutomatically; elModelTextures.value = properties.textures; - elModelOriginalTextures.value = properties.originalTextures; + elModelOriginalTextures.value = properties.originalTextures; } else if (properties.type == "Web") { for (var i = 0; i < elWebSections.length; i++) { elWebSections[i].style.display = 'block'; @@ -618,16 +619,16 @@ elParticleLifeSpan.value = properties.lifespan.toFixed(2); elParticleEmitRate.value = properties.emitRate.toFixed(1); elParticleRadius.value = properties.particleRadius.toFixed(3); + elParticleTextures.value = properties.textures; - /* - COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(colorSpread, getColorSpread); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(colorStart, getColorStart); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(colorFinish, getColorFinish); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(alphaSpread, getAlphaSpread); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(alphaStart, getAlphaStart); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(alphaFinish, getAlphaFinish); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures); + // FIXME - these are other particle properties we could support in the editor + // shapeType // ??? + // color colorSpread + // color colorStart + // color colorFinish + // float alphaSpread + // float alphaStart + // float alphaFinish // float emitSpeed // float speedSpread // quat emitOrientation @@ -643,7 +644,6 @@ // float radiusSpread?? // float radiusFinish // float RadiusSpread - */ } else if (properties.type == "PolyVox") { for (var i = 0; i < elPolyVoxSections.length; i++) { @@ -782,6 +782,7 @@ elParticleLifeSpan.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifespan')); elParticleEmitRate.addEventListener('change', createEmitNumberPropertyUpdateFunction('emitRate')); elParticleRadius.addEventListener('change', createEmitNumberPropertyUpdateFunction('particleRadius')); + elParticleTextures.addEventListener('change', createEmitTextPropertyUpdateFunction('textures')); elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL')); elShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType')); @@ -1405,6 +1406,12 @@
+
+
Textures
+
+ +
+
diff --git a/libraries/entities/src/ParticleEffectEntityItem.cpp b/libraries/entities/src/ParticleEffectEntityItem.cpp index d04f192f80..f6ed4a06ab 100644 --- a/libraries/entities/src/ParticleEffectEntityItem.cpp +++ b/libraries/entities/src/ParticleEffectEntityItem.cpp @@ -329,7 +329,7 @@ EntityItemProperties ParticleEffectEntityItem::getProperties(EntityPropertyFlags COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getXColor); COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha); COPY_ENTITY_PROPERTY_TO_PROPERTIES(glowLevel, getGlowLevel); - COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); + COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType); // FIXME - this doesn't appear to get used COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxParticles, getMaxParticles); COPY_ENTITY_PROPERTY_TO_PROPERTIES(lifespan, getLifespan); COPY_ENTITY_PROPERTY_TO_PROPERTIES(isEmitting, getIsEmitting); From 39f2241eacc812507e06eb792c8adca27607cf38 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 8 Oct 2015 09:46:43 -0700 Subject: [PATCH 3/5] fix coding standard issue --- examples/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/edit.js b/examples/edit.js index 98ad21f4e2..0a1f31f0d7 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -1275,7 +1275,7 @@ PropertiesTool = function(opts) { webView.eventBridge.emitScriptEvent(JSON.stringify(data)); }); - webView.eventBridge.webEventReceived.connect(function (data) { + webView.eventBridge.webEventReceived.connect(function(data) { data = JSON.parse(data); if (data.type == "print") { if (data.message) { From a8d162248176d49b5490d4cf782cbecdc1b4deff Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 8 Oct 2015 11:47:54 -0700 Subject: [PATCH 4/5] CR feedback --- examples/html/entityProperties.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index dcb49477d8..1bf3458efd 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -1349,13 +1349,13 @@
Textures
- +
Original Textures
- +
@@ -1403,13 +1403,13 @@
Particle Radius
- +
Textures
- +
From f1410269909e31fccc5d7c1ab545b0350e027289 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Thu, 8 Oct 2015 11:48:48 -0700 Subject: [PATCH 5/5] CR feedback --- examples/html/entityProperties.html | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index 1bf3458efd..97d8fe4729 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -621,30 +621,6 @@ elParticleRadius.value = properties.particleRadius.toFixed(3); elParticleTextures.value = properties.textures; - // FIXME - these are other particle properties we could support in the editor - // shapeType // ??? - // color colorSpread - // color colorStart - // color colorFinish - // float alphaSpread - // float alphaStart - // float alphaFinish - // float emitSpeed - // float speedSpread - // quat emitOrientation - // vec3 emitDimensions - // float emitRadiusStart - // float polarStart - // float polarFinish - // float azimuthStart - // float azimuthFinish - // vec3 emitAcceleration - // vec3 accelerationSpread - // float radiusStart - // float radiusSpread?? - // float radiusFinish - // float RadiusSpread - } else if (properties.type == "PolyVox") { for (var i = 0; i < elPolyVoxSections.length; i++) { elPolyVoxSections[i].style.display = 'block';