mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:58:07 +02:00
add pulse group properties to shapes, particles, text, web, image, and grid
This commit is contained in:
parent
9803043512
commit
611998f799
37 changed files with 824 additions and 57 deletions
|
@ -141,7 +141,7 @@ std::shared_ptr<T> make_renderer(const EntityItemPointer& entity) {
|
||||||
return std::shared_ptr<T>(new T(entity), [](T* ptr) { ptr->deleteLater(); });
|
return std::shared_ptr<T>(new T(entity), [](T* ptr) { ptr->deleteLater(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityRenderer::EntityRenderer(const EntityItemPointer& entity) : _entity(entity) {
|
EntityRenderer::EntityRenderer(const EntityItemPointer& entity) : _entity(entity), _created(entity->getCreated()) {
|
||||||
connect(entity.get(), &EntityItem::requestRenderUpdate, this, [&] {
|
connect(entity.get(), &EntityItem::requestRenderUpdate, this, [&] {
|
||||||
_needsRenderUpdate = true;
|
_needsRenderUpdate = true;
|
||||||
emit requestRenderUpdate();
|
emit requestRenderUpdate();
|
||||||
|
@ -468,3 +468,32 @@ void EntityRenderer::removeMaterial(graphics::MaterialPointer material, const st
|
||||||
std::lock_guard<std::mutex> lock(_materialsLock);
|
std::lock_guard<std::mutex> lock(_materialsLock);
|
||||||
_materials[parentMaterialName].remove(material);
|
_materials[parentMaterialName].remove(material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec4 EntityRenderer::calculatePulseColor(const glm::vec4& color, const PulsePropertyGroup& pulseProperties, quint64 start) {
|
||||||
|
if (pulseProperties.getPeriod() == 0.0f || (pulseProperties.getColorMode() == PulseMode::NONE && pulseProperties.getAlphaMode() == PulseMode::NONE)) {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
float t = ((float)(usecTimestampNow() - start)) / ((float)USECS_PER_SECOND);
|
||||||
|
float pulse = 0.5f * (glm::cos(t * (2.0f * M_PI) / pulseProperties.getPeriod()) + 1.0f) * (pulseProperties.getMax() - pulseProperties.getMin()) + pulseProperties.getMin();
|
||||||
|
float outPulse = (1.0f - pulse);
|
||||||
|
|
||||||
|
glm::vec4 result = color;
|
||||||
|
if (pulseProperties.getColorMode() == PulseMode::IN_PHASE) {
|
||||||
|
result.r *= pulse;
|
||||||
|
result.g *= pulse;
|
||||||
|
result.b *= pulse;
|
||||||
|
} else if (pulseProperties.getColorMode() == PulseMode::OUT_PHASE) {
|
||||||
|
result.r *= outPulse;
|
||||||
|
result.g *= outPulse;
|
||||||
|
result.b *= outPulse;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pulseProperties.getAlphaMode() == PulseMode::IN_PHASE) {
|
||||||
|
result.a *= pulse;
|
||||||
|
} else if (pulseProperties.getAlphaMode() == PulseMode::OUT_PHASE) {
|
||||||
|
result.a *= outPulse;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -62,6 +62,8 @@ public:
|
||||||
|
|
||||||
virtual scriptable::ScriptableModelBase getScriptableModel() override { return scriptable::ScriptableModelBase(); }
|
virtual scriptable::ScriptableModelBase getScriptableModel() override { return scriptable::ScriptableModelBase(); }
|
||||||
|
|
||||||
|
static glm::vec4 calculatePulseColor(const glm::vec4& color, const PulsePropertyGroup& pulseProperties, quint64 start);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool needsRenderUpdateFromEntity() const final { return needsRenderUpdateFromEntity(_entity); }
|
virtual bool needsRenderUpdateFromEntity() const final { return needsRenderUpdateFromEntity(_entity); }
|
||||||
virtual void onAddToScene(const EntityItemPointer& entity);
|
virtual void onAddToScene(const EntityItemPointer& entity);
|
||||||
|
@ -151,6 +153,8 @@ protected:
|
||||||
std::unordered_map<std::string, graphics::MultiMaterial> _materials;
|
std::unordered_map<std::string, graphics::MultiMaterial> _materials;
|
||||||
std::mutex _materialsLock;
|
std::mutex _materialsLock;
|
||||||
|
|
||||||
|
quint64 _created;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The base class relies on comparing the model transform to the entity transform in order
|
// The base class relies on comparing the model transform to the entity transform in order
|
||||||
// to trigger an update, so the member must not be visible to derived classes as a modifiable
|
// to trigger an update, so the member must not be visible to derived classes as a modifiable
|
||||||
|
|
|
@ -26,7 +26,7 @@ GridEntityRenderer::~GridEntityRenderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GridEntityRenderer::isTransparent() const {
|
bool GridEntityRenderer::isTransparent() const {
|
||||||
return Parent::isTransparent() || _alpha < 1.0f;
|
return Parent::isTransparent() || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GridEntityRenderer::needsRenderUpdate() const {
|
bool GridEntityRenderer::needsRenderUpdate() const {
|
||||||
|
@ -55,6 +55,10 @@ bool GridEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pulseProperties != entity->getPulseProperties()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,6 +69,7 @@ void GridEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
_color = entity->getColor();
|
_color = entity->getColor();
|
||||||
_alpha = entity->getAlpha();
|
_alpha = entity->getAlpha();
|
||||||
|
_pulseProperties = entity->getPulseProperties();
|
||||||
|
|
||||||
_followCamera = entity->getFollowCamera();
|
_followCamera = entity->getFollowCamera();
|
||||||
_majorGridEvery = entity->getMajorGridEvery();
|
_majorGridEvery = entity->getMajorGridEvery();
|
||||||
|
@ -105,11 +110,12 @@ ShapeKey GridEntityRenderer::getShapeKey() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridEntityRenderer::doRender(RenderArgs* args) {
|
void GridEntityRenderer::doRender(RenderArgs* args) {
|
||||||
glm::u8vec3 color;
|
glm::vec4 color;
|
||||||
glm::vec3 dimensions;
|
glm::vec3 dimensions;
|
||||||
Transform renderTransform;
|
Transform renderTransform;
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
color = _color;
|
color = glm::vec4(toGlm(_color), _alpha);
|
||||||
|
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
|
||||||
dimensions = _dimensions;
|
dimensions = _dimensions;
|
||||||
renderTransform = _renderTransform;
|
renderTransform = _renderTransform;
|
||||||
});
|
});
|
||||||
|
@ -141,12 +147,11 @@ void GridEntityRenderer::doRender(RenderArgs* args) {
|
||||||
float majorGridColDivisions = dimensions.y / _majorGridEvery;
|
float majorGridColDivisions = dimensions.y / _majorGridEvery;
|
||||||
float minorGridRowDivisions = dimensions.x / _minorGridEvery;
|
float minorGridRowDivisions = dimensions.x / _minorGridEvery;
|
||||||
float minorGridColDivisions = dimensions.y / _minorGridEvery;
|
float minorGridColDivisions = dimensions.y / _minorGridEvery;
|
||||||
glm::vec4 gridColor(toGlm(color), _alpha);
|
|
||||||
|
|
||||||
const float MINOR_GRID_EDGE = 0.0025f;
|
const float MINOR_GRID_EDGE = 0.0025f;
|
||||||
const float MAJOR_GRID_EDGE = 0.005f;
|
const float MAJOR_GRID_EDGE = 0.005f;
|
||||||
DependencyManager::get<GeometryCache>()->renderGrid(*batch, minCorner, maxCorner,
|
DependencyManager::get<GeometryCache>()->renderGrid(*batch, minCorner, maxCorner,
|
||||||
minorGridRowDivisions, minorGridColDivisions, MINOR_GRID_EDGE,
|
minorGridRowDivisions, minorGridColDivisions, MINOR_GRID_EDGE,
|
||||||
majorGridRowDivisions, majorGridColDivisions, MAJOR_GRID_EDGE,
|
majorGridRowDivisions, majorGridColDivisions, MAJOR_GRID_EDGE,
|
||||||
gridColor, _geometryId);
|
color, _geometryId);
|
||||||
}
|
}
|
|
@ -36,6 +36,7 @@ private:
|
||||||
|
|
||||||
glm::u8vec3 _color;
|
glm::u8vec3 _color;
|
||||||
float _alpha;
|
float _alpha;
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
|
|
||||||
bool _followCamera;
|
bool _followCamera;
|
||||||
uint32_t _majorGridEvery;
|
uint32_t _majorGridEvery;
|
||||||
|
|
|
@ -26,7 +26,7 @@ ImageEntityRenderer::~ImageEntityRenderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageEntityRenderer::isTransparent() const {
|
bool ImageEntityRenderer::isTransparent() const {
|
||||||
return Parent::isTransparent() || (_textureIsLoaded && _texture->getGPUTexture() && _texture->getGPUTexture()->getUsage().isAlpha()) || _alpha < 1.0f;
|
return Parent::isTransparent() || (_textureIsLoaded && _texture->getGPUTexture() && _texture->getGPUTexture()->getUsage().isAlpha()) || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImageEntityRenderer::needsRenderUpdate() const {
|
bool ImageEntityRenderer::needsRenderUpdate() const {
|
||||||
|
@ -71,6 +71,10 @@ bool ImageEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pulseProperties != entity->getPulseProperties()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -97,6 +101,7 @@ void ImageEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
|
|
||||||
_color = entity->getColor();
|
_color = entity->getColor();
|
||||||
_alpha = entity->getAlpha();
|
_alpha = entity->getAlpha();
|
||||||
|
_pulseProperties = entity->getPulseProperties();
|
||||||
|
|
||||||
if (!_textureIsLoaded && _texture && _texture->isLoaded()) {
|
if (!_textureIsLoaded && _texture && _texture->isLoaded()) {
|
||||||
_textureIsLoaded = true;
|
_textureIsLoaded = true;
|
||||||
|
@ -135,13 +140,14 @@ ShapeKey ImageEntityRenderer::getShapeKey() {
|
||||||
void ImageEntityRenderer::doRender(RenderArgs* args) {
|
void ImageEntityRenderer::doRender(RenderArgs* args) {
|
||||||
NetworkTexturePointer texture;
|
NetworkTexturePointer texture;
|
||||||
QRect subImage;
|
QRect subImage;
|
||||||
glm::u8vec3 color;
|
glm::vec4 color;
|
||||||
glm::vec3 dimensions;
|
glm::vec3 dimensions;
|
||||||
Transform transform;
|
Transform transform;
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
texture = _texture;
|
texture = _texture;
|
||||||
subImage = _subImage;
|
subImage = _subImage;
|
||||||
color = _color;
|
color = glm::vec4(toGlm(_color), _alpha);
|
||||||
|
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
|
||||||
dimensions = _dimensions;
|
dimensions = _dimensions;
|
||||||
transform = _renderTransform;
|
transform = _renderTransform;
|
||||||
});
|
});
|
||||||
|
@ -211,11 +217,9 @@ void ImageEntityRenderer::doRender(RenderArgs* args) {
|
||||||
glm::vec2 texCoordBottomRight((fromImage.x() + fromImage.width() - 0.5f) / imageWidth,
|
glm::vec2 texCoordBottomRight((fromImage.x() + fromImage.width() - 0.5f) / imageWidth,
|
||||||
(fromImage.y() + fromImage.height() - 0.5f) / imageHeight);
|
(fromImage.y() + fromImage.height() - 0.5f) / imageHeight);
|
||||||
|
|
||||||
glm::vec4 imageColor(toGlm(color), _alpha);
|
|
||||||
|
|
||||||
DependencyManager::get<GeometryCache>()->renderQuad(
|
DependencyManager::get<GeometryCache>()->renderQuad(
|
||||||
*batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
*batch, topLeft, bottomRight, texCoordTopLeft, texCoordBottomRight,
|
||||||
imageColor, _geometryId
|
color, _geometryId
|
||||||
);
|
);
|
||||||
|
|
||||||
batch->setResourceTexture(0, nullptr);
|
batch->setResourceTexture(0, nullptr);
|
||||||
|
|
|
@ -44,6 +44,7 @@ private:
|
||||||
|
|
||||||
glm::u8vec3 _color;
|
glm::u8vec3 _color;
|
||||||
float _alpha;
|
float _alpha;
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
|
|
||||||
glm::vec3 _dimensions;
|
glm::vec3 _dimensions;
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,11 @@ bool ParticleEffectEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto particleProperties = entity->getParticleProperties();
|
if (_particleProperties != entity->getParticleProperties()) {
|
||||||
if (particleProperties != _particleProperties) {
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_pulseProperties != entity->getPulseProperties()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +98,10 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
withWriteLock([&] {
|
||||||
|
_pulseProperties = entity->getPulseProperties();
|
||||||
|
});
|
||||||
_emitting = entity->getIsEmitting();
|
_emitting = entity->getIsEmitting();
|
||||||
|
|
||||||
bool hasTexture = resultWithReadLock<bool>([&]{ return _particleProperties.textures.isEmpty(); });
|
bool hasTexture = resultWithReadLock<bool>([&]{ return _particleProperties.textures.isEmpty(); });
|
||||||
|
@ -142,10 +149,6 @@ void ParticleEffectEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEn
|
||||||
particleUniforms.radius.middle = _particleProperties.radius.gradient.target;
|
particleUniforms.radius.middle = _particleProperties.radius.gradient.target;
|
||||||
particleUniforms.radius.finish = _particleProperties.radius.range.finish;
|
particleUniforms.radius.finish = _particleProperties.radius.range.finish;
|
||||||
particleUniforms.radius.spread = _particleProperties.radius.gradient.spread;
|
particleUniforms.radius.spread = _particleProperties.radius.gradient.spread;
|
||||||
particleUniforms.color.start = _particleProperties.getColorStart();
|
|
||||||
particleUniforms.color.middle = _particleProperties.getColorMiddle();
|
|
||||||
particleUniforms.color.finish = _particleProperties.getColorFinish();
|
|
||||||
particleUniforms.color.spread = _particleProperties.getColorSpread();
|
|
||||||
particleUniforms.spin.start = _particleProperties.spin.range.start;
|
particleUniforms.spin.start = _particleProperties.spin.range.start;
|
||||||
particleUniforms.spin.middle = _particleProperties.spin.gradient.target;
|
particleUniforms.spin.middle = _particleProperties.spin.gradient.target;
|
||||||
particleUniforms.spin.finish = _particleProperties.spin.range.finish;
|
particleUniforms.spin.finish = _particleProperties.spin.range.finish;
|
||||||
|
@ -158,6 +161,7 @@ void ParticleEffectEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEn
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemKey ParticleEffectEntityRenderer::getKey() {
|
ItemKey ParticleEffectEntityRenderer::getKey() {
|
||||||
|
// FIXME: implement isTransparent() for particles and an opaque pipeline
|
||||||
if (_visible) {
|
if (_visible) {
|
||||||
return ItemKey::Builder::transparentShape().withTagBits(getTagMask()).withLayer(getHifiRenderLayer());
|
return ItemKey::Builder::transparentShape().withTagBits(getTagMask()).withLayer(getHifiRenderLayer());
|
||||||
} else {
|
} else {
|
||||||
|
@ -339,7 +343,13 @@ void ParticleEffectEntityRenderer::doRender(RenderArgs* args) {
|
||||||
// if the particles are marked rotateWithEntity
|
// if the particles are marked rotateWithEntity
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
transform.setRotation(_renderTransform.getRotation());
|
transform.setRotation(_renderTransform.getRotation());
|
||||||
|
auto& color = _uniformBuffer.edit<ParticleUniforms>().color;
|
||||||
|
color.start = EntityRenderer::calculatePulseColor(_particleProperties.getColorStart(), _pulseProperties, _created);
|
||||||
|
color.middle = EntityRenderer::calculatePulseColor(_particleProperties.getColorMiddle(), _pulseProperties, _created);
|
||||||
|
color.finish = EntityRenderer::calculatePulseColor(_particleProperties.getColorFinish(), _pulseProperties, _created);
|
||||||
|
color.spread = EntityRenderer::calculatePulseColor(_particleProperties.getColorSpread(), _pulseProperties, _created);
|
||||||
});
|
});
|
||||||
|
|
||||||
batch.setModelTransform(transform);
|
batch.setModelTransform(transform);
|
||||||
batch.setUniformBuffer(0, _uniformBuffer);
|
batch.setUniformBuffer(0, _uniformBuffer);
|
||||||
batch.setInputFormat(_vertexFormat);
|
batch.setInputFormat(_vertexFormat);
|
||||||
|
|
|
@ -94,6 +94,8 @@ private:
|
||||||
BufferView _uniformBuffer;
|
BufferView _uniformBuffer;
|
||||||
quint64 _lastSimulated { 0 };
|
quint64 _lastSimulated { 0 };
|
||||||
|
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
|
|
||||||
NetworkTexturePointer _networkTexture;
|
NetworkTexturePointer _networkTexture;
|
||||||
ScenePointer _scene;
|
ScenePointer _scene;
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,6 +68,10 @@ bool ShapeEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoin
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pulseProperties != entity->getPulseProperties()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +88,7 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
||||||
addMaterial(graphics::MaterialLayer(_material, 0), "0");
|
addMaterial(graphics::MaterialLayer(_material, 0), "0");
|
||||||
|
|
||||||
_shape = entity->getShape();
|
_shape = entity->getShape();
|
||||||
|
_pulseProperties = entity->getPulseProperties();
|
||||||
});
|
});
|
||||||
|
|
||||||
void* key = (void*)this;
|
void* key = (void*)this;
|
||||||
|
@ -114,6 +119,10 @@ void ShapeEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShapeEntityRenderer::isTransparent() const {
|
bool ShapeEntityRenderer::isTransparent() const {
|
||||||
|
if (_pulseProperties.getAlphaMode() != PulseMode::NONE) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (_procedural.isEnabled() && _procedural.isFading()) {
|
if (_procedural.isEnabled() && _procedural.isFading()) {
|
||||||
return Interpolate::calculateFadeRatio(_procedural.getFadeStartTime()) < 1.0f;
|
return Interpolate::calculateFadeRatio(_procedural.getFadeStartTime()) < 1.0f;
|
||||||
}
|
}
|
||||||
|
@ -227,6 +236,7 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) {
|
||||||
mat = _materials["0"].top().material;
|
mat = _materials["0"].top().material;
|
||||||
if (mat) {
|
if (mat) {
|
||||||
outColor = glm::vec4(mat->getAlbedo(), mat->getOpacity());
|
outColor = glm::vec4(mat->getAlbedo(), mat->getOpacity());
|
||||||
|
outColor = EntityRenderer::calculatePulseColor(outColor, _pulseProperties, _created);
|
||||||
if (_procedural.isReady()) {
|
if (_procedural.isReady()) {
|
||||||
outColor = _procedural.getColor(outColor);
|
outColor = _procedural.getColor(outColor);
|
||||||
outColor.a *= _procedural.isFading() ? Interpolate::calculateFadeRatio(_procedural.getFadeStartTime()) : 1.0f;
|
outColor.a *= _procedural.isFading() ? Interpolate::calculateFadeRatio(_procedural.getFadeStartTime()) : 1.0f;
|
||||||
|
|
|
@ -40,6 +40,7 @@ private:
|
||||||
Procedural _procedural;
|
Procedural _procedural;
|
||||||
QString _lastUserData;
|
QString _lastUserData;
|
||||||
entity::Shape _shape { entity::Sphere };
|
entity::Shape _shape { entity::Sphere };
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
std::shared_ptr<graphics::Material> _material;
|
std::shared_ptr<graphics::Material> _material;
|
||||||
glm::vec3 _position;
|
glm::vec3 _position;
|
||||||
glm::vec3 _dimensions;
|
glm::vec3 _dimensions;
|
||||||
|
|
|
@ -41,7 +41,7 @@ TextEntityRenderer::~TextEntityRenderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextEntityRenderer::isTransparent() const {
|
bool TextEntityRenderer::isTransparent() const {
|
||||||
return Parent::isTransparent() || _textAlpha < 1.0f || _backgroundAlpha < 1.0f;
|
return Parent::isTransparent() || _textAlpha < 1.0f || _backgroundAlpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeKey TextEntityRenderer::getShapeKey() {
|
ShapeKey TextEntityRenderer::getShapeKey() {
|
||||||
|
@ -104,6 +104,10 @@ bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pulseProperties != entity->getPulseProperties()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,32 +123,39 @@ void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
|
||||||
_text = entity->getText();
|
withWriteLock([&] {
|
||||||
_lineHeight = entity->getLineHeight();
|
_pulseProperties = entity->getPulseProperties();
|
||||||
_textColor = toGlm(entity->getTextColor());
|
_text = entity->getText();
|
||||||
_textAlpha = entity->getTextAlpha();
|
_lineHeight = entity->getLineHeight();
|
||||||
_backgroundColor = toGlm(entity->getBackgroundColor());
|
_textColor = toGlm(entity->getTextColor());
|
||||||
_backgroundAlpha = entity->getBackgroundAlpha();
|
_textAlpha = entity->getTextAlpha();
|
||||||
_billboardMode = entity->getBillboardMode();
|
_backgroundColor = toGlm(entity->getBackgroundColor());
|
||||||
_leftMargin = entity->getLeftMargin();
|
_backgroundAlpha = entity->getBackgroundAlpha();
|
||||||
_rightMargin = entity->getRightMargin();
|
_billboardMode = entity->getBillboardMode();
|
||||||
_topMargin = entity->getTopMargin();
|
_leftMargin = entity->getLeftMargin();
|
||||||
_bottomMargin = entity->getBottomMargin();
|
_rightMargin = entity->getRightMargin();
|
||||||
|
_topMargin = entity->getTopMargin();
|
||||||
|
_bottomMargin = entity->getBottomMargin();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEntityRenderer::doRender(RenderArgs* args) {
|
void TextEntityRenderer::doRender(RenderArgs* args) {
|
||||||
PerformanceTimer perfTimer("RenderableTextEntityItem::render");
|
PerformanceTimer perfTimer("RenderableTextEntityItem::render");
|
||||||
|
|
||||||
|
glm::vec4 textColor;
|
||||||
|
glm::vec4 backgroundColor;
|
||||||
Transform modelTransform;
|
Transform modelTransform;
|
||||||
glm::vec3 dimensions;
|
glm::vec3 dimensions;
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
modelTransform = _renderTransform;
|
modelTransform = _renderTransform;
|
||||||
dimensions = _dimensions;
|
dimensions = _dimensions;
|
||||||
});
|
|
||||||
|
|
||||||
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
||||||
glm::vec4 textColor = glm::vec4(_textColor, fadeRatio * _textAlpha);
|
textColor = glm::vec4(_textColor, fadeRatio * _textAlpha);
|
||||||
glm::vec4 backgroundColor = glm::vec4(_backgroundColor, fadeRatio * _backgroundAlpha);
|
textColor = EntityRenderer::calculatePulseColor(textColor, _pulseProperties, _created);
|
||||||
|
backgroundColor = glm::vec4(_backgroundColor, fadeRatio * _backgroundAlpha);
|
||||||
|
backgroundColor = EntityRenderer::calculatePulseColor(backgroundColor, _pulseProperties, _created);
|
||||||
|
});
|
||||||
|
|
||||||
// Render background
|
// Render background
|
||||||
static const float SLIGHTLY_BEHIND = -0.005f;
|
static const float SLIGHTLY_BEHIND = -0.005f;
|
||||||
|
|
|
@ -38,6 +38,8 @@ private:
|
||||||
int _geometryID{ 0 };
|
int _geometryID{ 0 };
|
||||||
std::shared_ptr<TextRenderer3D> _textRenderer;
|
std::shared_ptr<TextRenderer3D> _textRenderer;
|
||||||
|
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
|
|
||||||
QString _text;
|
QString _text;
|
||||||
float _lineHeight;
|
float _lineHeight;
|
||||||
glm::vec3 _textColor;
|
glm::vec3 _textColor;
|
||||||
|
|
|
@ -97,7 +97,7 @@ WebEntityRenderer::~WebEntityRenderer() {
|
||||||
|
|
||||||
bool WebEntityRenderer::isTransparent() const {
|
bool WebEntityRenderer::isTransparent() const {
|
||||||
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
||||||
return fadeRatio < OPAQUE_ALPHA_THRESHOLD || _alpha < 1.0f;
|
return fadeRatio < OPAQUE_ALPHA_THRESHOLD || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
|
bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
|
||||||
|
@ -143,6 +143,10 @@ bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_pulseProperties != entity->getPulseProperties()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,6 +205,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
|
||||||
_dpi = entity->getDPI();
|
_dpi = entity->getDPI();
|
||||||
_color = entity->getColor();
|
_color = entity->getColor();
|
||||||
_alpha = entity->getAlpha();
|
_alpha = entity->getAlpha();
|
||||||
|
_pulseProperties = entity->getPulseProperties();
|
||||||
|
|
||||||
if (_contentType == ContentType::NoContent) {
|
if (_contentType == ContentType::NoContent) {
|
||||||
return;
|
return;
|
||||||
|
@ -293,6 +298,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
|
||||||
color = glm::vec4(toGlm(_color), _alpha * fadeRatio);
|
color = glm::vec4(toGlm(_color), _alpha * fadeRatio);
|
||||||
|
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
|
||||||
batch.setModelTransform(_renderTransform);
|
batch.setModelTransform(_renderTransform);
|
||||||
});
|
});
|
||||||
batch.setResourceTexture(0, _texture);
|
batch.setResourceTexture(0, _texture);
|
||||||
|
|
|
@ -84,6 +84,7 @@ private:
|
||||||
|
|
||||||
glm::u8vec3 _color;
|
glm::u8vec3 _color;
|
||||||
float _alpha { 1.0f };
|
float _alpha { 1.0f };
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
|
|
||||||
QString _sourceURL;
|
QString _sourceURL;
|
||||||
uint16_t _dpi;
|
uint16_t _dpi;
|
||||||
|
|
|
@ -98,9 +98,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
|
||||||
requestedProperties += PROP_RENDER_LAYER;
|
requestedProperties += PROP_RENDER_LAYER;
|
||||||
requestedProperties += PROP_PRIMITIVE_MODE;
|
requestedProperties += PROP_PRIMITIVE_MODE;
|
||||||
requestedProperties += PROP_IGNORE_PICK_INTERSECTION;
|
requestedProperties += PROP_IGNORE_PICK_INTERSECTION;
|
||||||
withReadLock([&] {
|
requestedProperties += _grabProperties.getEntityProperties(params);
|
||||||
requestedProperties += _grabProperties.getEntityProperties(params);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Physics
|
// Physics
|
||||||
requestedProperties += PROP_DENSITY;
|
requestedProperties += PROP_DENSITY;
|
||||||
|
|
|
@ -41,6 +41,7 @@ BloomPropertyGroup EntityItemProperties::_staticBloom;
|
||||||
KeyLightPropertyGroup EntityItemProperties::_staticKeyLight;
|
KeyLightPropertyGroup EntityItemProperties::_staticKeyLight;
|
||||||
AmbientLightPropertyGroup EntityItemProperties::_staticAmbientLight;
|
AmbientLightPropertyGroup EntityItemProperties::_staticAmbientLight;
|
||||||
GrabPropertyGroup EntityItemProperties::_staticGrab;
|
GrabPropertyGroup EntityItemProperties::_staticGrab;
|
||||||
|
PulsePropertyGroup EntityItemProperties::_staticPulse;
|
||||||
|
|
||||||
EntityPropertyList PROP_LAST_ITEM = (EntityPropertyList)(PROP_AFTER_LAST_ITEM - 1);
|
EntityPropertyList PROP_LAST_ITEM = (EntityPropertyList)(PROP_AFTER_LAST_ITEM - 1);
|
||||||
|
|
||||||
|
@ -503,6 +504,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
CHECK_PROPERTY_CHANGE(PROP_COMPOUND_SHAPE_URL, compoundShapeURL);
|
CHECK_PROPERTY_CHANGE(PROP_COMPOUND_SHAPE_URL, compoundShapeURL);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_COLOR, color);
|
CHECK_PROPERTY_CHANGE(PROP_COLOR, color);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_ALPHA, alpha);
|
CHECK_PROPERTY_CHANGE(PROP_ALPHA, alpha);
|
||||||
|
changedProperties += _pulse.getChangedProperties();
|
||||||
CHECK_PROPERTY_CHANGE(PROP_TEXTURES, textures);
|
CHECK_PROPERTY_CHANGE(PROP_TEXTURES, textures);
|
||||||
|
|
||||||
// Particles
|
// Particles
|
||||||
|
@ -1100,6 +1102,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* and <code>spinSpread == PI/2</code>, each particle will have a spin in the range <code>PI/2</code> – <code>3*PI/2</code>.
|
* and <code>spinSpread == PI/2</code>, each particle will have a spin in the range <code>PI/2</code> – <code>3*PI/2</code>.
|
||||||
* @property {boolean} rotateWithEntity=false - Whether or not the particles' spin will rotate with the entity. If false, when <code>particleSpin == 0</code>, the particles will point
|
* @property {boolean} rotateWithEntity=false - Whether or not the particles' spin will rotate with the entity. If false, when <code>particleSpin == 0</code>, the particles will point
|
||||||
* up in the world. If true, they will point towards the entity's up vector, based on its orientation.
|
* up in the world. If true, they will point towards the entity's up vector, based on its orientation.
|
||||||
|
* @property {Entities.Pulse} pulse - The pulse-related properties.
|
||||||
*
|
*
|
||||||
* @property {ShapeType} shapeType="none" - <em>Currently not used.</em> <em>Read-only.</em>
|
* @property {ShapeType} shapeType="none" - <em>Currently not used.</em> <em>Read-only.</em>
|
||||||
*
|
*
|
||||||
|
@ -1227,6 +1230,8 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* @property {Entities.Shape} shape="Sphere" - The shape of the entity.
|
* @property {Entities.Shape} shape="Sphere" - The shape of the entity.
|
||||||
* @property {Vec3} dimensions=0.1,0.1,0.1 - The dimensions of the entity.
|
* @property {Vec3} dimensions=0.1,0.1,0.1 - The dimensions of the entity.
|
||||||
* @property {Color} color=255,255,255 - The color of the entity.
|
* @property {Color} color=255,255,255 - The color of the entity.
|
||||||
|
* @property {number} alpha=1 - The alpha of the shape.
|
||||||
|
* @property {Entities.Pulse} pulse - The pulse-related properties.
|
||||||
* @example <caption>Create a cylinder.</caption>
|
* @example <caption>Create a cylinder.</caption>
|
||||||
* var shape = Entities.addEntity({
|
* var shape = Entities.addEntity({
|
||||||
* type: "Shape",
|
* type: "Shape",
|
||||||
|
@ -1266,6 +1271,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* @property {number} rightMargin=0.0 - The right margin, in meters.
|
* @property {number} rightMargin=0.0 - The right margin, in meters.
|
||||||
* @property {number} topMargin=0.0 - The top margin, in meters.
|
* @property {number} topMargin=0.0 - The top margin, in meters.
|
||||||
* @property {number} bottomMargin=0.0 - The bottom margin, in meters.
|
* @property {number} bottomMargin=0.0 - The bottom margin, in meters.
|
||||||
|
* @property {Entities.Pulse} pulse - The pulse-related properties.
|
||||||
* @example <caption>Create a text entity.</caption>
|
* @example <caption>Create a text entity.</caption>
|
||||||
* var text = Entities.addEntity({
|
* var text = Entities.addEntity({
|
||||||
* type: "Text",
|
* type: "Text",
|
||||||
|
@ -1295,6 +1301,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* @property {string} scriptURL="" - The URL of a JavaScript file to inject into the Web page.
|
* @property {string} scriptURL="" - The URL of a JavaScript file to inject into the Web page.
|
||||||
* @property {number} maxFPS=10 - The maximum update rate for the Web content, in frames/second.
|
* @property {number} maxFPS=10 - The maximum update rate for the Web content, in frames/second.
|
||||||
* @property {WebInputMode} inputMode="touch" - The user input mode to use.
|
* @property {WebInputMode} inputMode="touch" - The user input mode to use.
|
||||||
|
* @property {Entities.Pulse} pulse - The pulse-related properties.
|
||||||
* @example <caption>Create a Web entity displaying at 1920 x 1080 resolution.</caption>
|
* @example <caption>Create a Web entity displaying at 1920 x 1080 resolution.</caption>
|
||||||
* var METERS_TO_INCHES = 39.3701;
|
* var METERS_TO_INCHES = 39.3701;
|
||||||
* var entity = Entities.addEntity({
|
* var entity = Entities.addEntity({
|
||||||
|
@ -1404,6 +1411,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* the full image in that dimension.
|
* the full image in that dimension.
|
||||||
* @property {Color} color=255,255,255 - The color of the image.
|
* @property {Color} color=255,255,255 - The color of the image.
|
||||||
* @property {number} alpha=1 - The alpha of the image.
|
* @property {number} alpha=1 - The alpha of the image.
|
||||||
|
* @property {Entities.Pulse} pulse - The pulse-related properties.
|
||||||
* @example <caption>Create a image entity.</caption>
|
* @example <caption>Create a image entity.</caption>
|
||||||
* var image = Entities.addEntity({
|
* var image = Entities.addEntity({
|
||||||
* type: "Image",
|
* type: "Image",
|
||||||
|
@ -1427,6 +1435,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* line. Minimum value = <code>1</code>.
|
* line. Minimum value = <code>1</code>.
|
||||||
* @property {number} minorGridEvery=1 - Real number of meters at which to draw thin grid lines. Minimum value =
|
* @property {number} minorGridEvery=1 - Real number of meters at which to draw thin grid lines. Minimum value =
|
||||||
* <code>0.001</code>.
|
* <code>0.001</code>.
|
||||||
|
* @property {Entities.Pulse} pulse - The pulse-related properties.
|
||||||
* @example <caption>Create a grid entity.</caption>
|
* @example <caption>Create a grid entity.</caption>
|
||||||
* var grid = Entities.addEntity({
|
* var grid = Entities.addEntity({
|
||||||
* type: "Grid",
|
* type: "Grid",
|
||||||
|
@ -1564,6 +1573,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_SHAPE_TYPE, shapeType, getShapeTypeAsString());
|
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_SHAPE_TYPE, shapeType, getShapeTypeAsString());
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
||||||
|
_pulse.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_TEXTURES, textures);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_TEXTURES, textures);
|
||||||
|
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_PARTICLES, maxParticles);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_PARTICLES, maxParticles);
|
||||||
|
@ -1637,6 +1647,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
if (_type == EntityTypes::Box || _type == EntityTypes::Sphere || _type == EntityTypes::Shape) {
|
if (_type == EntityTypes::Box || _type == EntityTypes::Sphere || _type == EntityTypes::Shape) {
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
||||||
|
_pulse.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHAPE, shape);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHAPE, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1652,6 +1663,8 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
|
|
||||||
// Text only
|
// Text only
|
||||||
if (_type == EntityTypes::Text) {
|
if (_type == EntityTypes::Text) {
|
||||||
|
_pulse.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||||
|
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_TEXT, text);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_TEXT, text);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LINE_HEIGHT, lineHeight);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LINE_HEIGHT, lineHeight);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_TYPED(PROP_TEXT_COLOR, textColor, getTextColor(), u8vec3Color);
|
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER_TYPED(PROP_TEXT_COLOR, textColor, getTextColor(), u8vec3Color);
|
||||||
|
@ -1693,6 +1706,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
if (_type == EntityTypes::Web) {
|
if (_type == EntityTypes::Web) {
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
||||||
|
_pulse.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||||
|
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SOURCE_URL, sourceUrl);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SOURCE_URL, sourceUrl);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_DPI, dpi);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_DPI, dpi);
|
||||||
|
@ -1757,6 +1771,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
if (_type == EntityTypes::Image) {
|
if (_type == EntityTypes::Image) {
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
||||||
|
_pulse.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||||
|
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IMAGE_URL, imageURL);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IMAGE_URL, imageURL);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_EMISSIVE, emissive);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_EMISSIVE, emissive);
|
||||||
|
@ -1777,6 +1792,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
if (_type == EntityTypes::Grid) {
|
if (_type == EntityTypes::Grid) {
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
COPY_PROPERTY_TO_QSCRIPTVALUE_TYPED(PROP_COLOR, color, u8vec3Color);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_ALPHA, alpha);
|
||||||
|
_pulse.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||||
|
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_GRID_FOLLOW_CAMERA, followCamera);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_GRID_FOLLOW_CAMERA, followCamera);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAJOR_GRID_EVERY, majorGridEvery);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAJOR_GRID_EVERY, majorGridEvery);
|
||||||
|
@ -1957,6 +1973,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(compoundShapeURL, QString, setCompoundShapeURL);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(compoundShapeURL, QString, setCompoundShapeURL);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(color, u8vec3Color, setColor);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(color, u8vec3Color, setColor);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(alpha, float, setAlpha);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(alpha, float, setAlpha);
|
||||||
|
_pulse.copyFromScriptValue(object, _defaultSettings);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(textures, QString, setTextures);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(textures, QString, setTextures);
|
||||||
|
|
||||||
// Particles
|
// Particles
|
||||||
|
@ -2218,6 +2235,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
|
||||||
COPY_PROPERTY_IF_CHANGED(compoundShapeURL);
|
COPY_PROPERTY_IF_CHANGED(compoundShapeURL);
|
||||||
COPY_PROPERTY_IF_CHANGED(color);
|
COPY_PROPERTY_IF_CHANGED(color);
|
||||||
COPY_PROPERTY_IF_CHANGED(alpha);
|
COPY_PROPERTY_IF_CHANGED(alpha);
|
||||||
|
_pulse.merge(other._pulse);
|
||||||
COPY_PROPERTY_IF_CHANGED(textures);
|
COPY_PROPERTY_IF_CHANGED(textures);
|
||||||
|
|
||||||
// Particles
|
// Particles
|
||||||
|
@ -2526,6 +2544,13 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr
|
||||||
ADD_PROPERTY_TO_MAP(PROP_COMPOUND_SHAPE_URL, CompoundShapeURL, compoundShapeURL, QString);
|
ADD_PROPERTY_TO_MAP(PROP_COMPOUND_SHAPE_URL, CompoundShapeURL, compoundShapeURL, QString);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_COLOR, Color, color, u8vec3Color);
|
ADD_PROPERTY_TO_MAP(PROP_COLOR, Color, color, u8vec3Color);
|
||||||
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA, Alpha, alpha, float, particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
|
ADD_PROPERTY_TO_MAP_WITH_RANGE(PROP_ALPHA, Alpha, alpha, float, particle::MINIMUM_ALPHA, particle::MAXIMUM_ALPHA);
|
||||||
|
{ // Pulse
|
||||||
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_PULSE_MIN, Pulse, pulse, Min, min);
|
||||||
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_PULSE_MAX, Pulse, pulse, Max, max);
|
||||||
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_PULSE_PERIOD, Pulse, pulse, Period, period);
|
||||||
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_PULSE_COLOR_MODE, Pulse, pulse, ColorMode, colorMode);
|
||||||
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_PULSE_ALPHA_MODE, Pulse, pulse, AlphaMode, alphaMode);
|
||||||
|
}
|
||||||
ADD_PROPERTY_TO_MAP(PROP_TEXTURES, Textures, textures, QString);
|
ADD_PROPERTY_TO_MAP(PROP_TEXTURES, Textures, textures, QString);
|
||||||
|
|
||||||
// Particles
|
// Particles
|
||||||
|
@ -2926,6 +2951,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)(properties.getShapeType()));
|
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)(properties.getShapeType()));
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
||||||
|
_staticPulse.setProperties(properties);
|
||||||
|
_staticPulse.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
||||||
|
propertiesDidntFit, propertyCount, appendState);
|
||||||
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, properties.getTextures());
|
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, properties.getTextures());
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_MAX_PARTICLES, properties.getMaxParticles());
|
APPEND_ENTITY_PROPERTY(PROP_MAX_PARTICLES, properties.getMaxParticles());
|
||||||
|
@ -2997,6 +3025,10 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Text) {
|
if (properties.getType() == EntityTypes::Text) {
|
||||||
|
_staticPulse.setProperties(properties);
|
||||||
|
_staticPulse.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
||||||
|
propertiesDidntFit, propertyCount, appendState);
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_TEXT, properties.getText());
|
APPEND_ENTITY_PROPERTY(PROP_TEXT, properties.getText());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_LINE_HEIGHT, properties.getLineHeight());
|
APPEND_ENTITY_PROPERTY(PROP_LINE_HEIGHT, properties.getLineHeight());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_TEXT_COLOR, properties.getTextColor());
|
APPEND_ENTITY_PROPERTY(PROP_TEXT_COLOR, properties.getTextColor());
|
||||||
|
@ -3058,6 +3090,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
if (properties.getType() == EntityTypes::Web) {
|
if (properties.getType() == EntityTypes::Web) {
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
||||||
|
_staticPulse.setProperties(properties);
|
||||||
|
_staticPulse.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
||||||
|
propertiesDidntFit, propertyCount, appendState);
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, properties.getSourceUrl());
|
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, properties.getSourceUrl());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_DPI, properties.getDPI());
|
APPEND_ENTITY_PROPERTY(PROP_DPI, properties.getDPI());
|
||||||
|
@ -3092,6 +3127,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
properties.getType() == EntityTypes::Sphere) {
|
properties.getType() == EntityTypes::Sphere) {
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
||||||
|
_staticPulse.setProperties(properties);
|
||||||
|
_staticPulse.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
||||||
|
propertiesDidntFit, propertyCount, appendState);
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE, properties.getShape());
|
APPEND_ENTITY_PROPERTY(PROP_SHAPE, properties.getShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3112,6 +3150,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
if (properties.getType() == EntityTypes::Image) {
|
if (properties.getType() == EntityTypes::Image) {
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
||||||
|
_staticPulse.setProperties(properties);
|
||||||
|
_staticPulse.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
||||||
|
propertiesDidntFit, propertyCount, appendState);
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_IMAGE_URL, properties.getImageURL());
|
APPEND_ENTITY_PROPERTY(PROP_IMAGE_URL, properties.getImageURL());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_EMISSIVE, properties.getEmissive());
|
APPEND_ENTITY_PROPERTY(PROP_EMISSIVE, properties.getEmissive());
|
||||||
|
@ -3124,6 +3165,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
if (properties.getType() == EntityTypes::Grid) {
|
if (properties.getType() == EntityTypes::Grid) {
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, properties.getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, properties.getAlpha());
|
||||||
|
_staticPulse.setProperties(properties);
|
||||||
|
_staticPulse.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
||||||
|
propertiesDidntFit, propertyCount, appendState);
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_GRID_FOLLOW_CAMERA, properties.getFollowCamera());
|
APPEND_ENTITY_PROPERTY(PROP_GRID_FOLLOW_CAMERA, properties.getFollowCamera());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_MAJOR_GRID_EVERY, properties.getMajorGridEvery());
|
APPEND_ENTITY_PROPERTY(PROP_MAJOR_GRID_EVERY, properties.getMajorGridEvery());
|
||||||
|
@ -3375,6 +3419,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE_TYPE, ShapeType, setShapeType);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE_TYPE, ShapeType, setShapeType);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
||||||
|
properties.getPulse().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXTURES, QString, setTextures);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXTURES, QString, setTextures);
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAX_PARTICLES, quint32, setMaxParticles);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAX_PARTICLES, quint32, setMaxParticles);
|
||||||
|
@ -3446,6 +3491,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Text) {
|
if (properties.getType() == EntityTypes::Text) {
|
||||||
|
properties.getPulse().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXT, QString, setText);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXT, QString, setText);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_HEIGHT, float, setLineHeight);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_LINE_HEIGHT, float, setLineHeight);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXT_COLOR, u8vec3Color, setTextColor);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TEXT_COLOR, u8vec3Color, setTextColor);
|
||||||
|
@ -3496,6 +3543,10 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Web) {
|
if (properties.getType() == EntityTypes::Web) {
|
||||||
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
||||||
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
||||||
|
properties.getPulse().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SOURCE_URL, QString, setSourceUrl);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SOURCE_URL, QString, setSourceUrl);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DPI, uint16_t, setDPI);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_DPI, uint16_t, setDPI);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SCRIPT_URL, QString, setScriptURL);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SCRIPT_URL, QString, setScriptURL);
|
||||||
|
@ -3529,6 +3580,8 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
properties.getType() == EntityTypes::Sphere) {
|
properties.getType() == EntityTypes::Sphere) {
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
||||||
|
properties.getPulse().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE, QString, setShape);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHAPE, QString, setShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3549,6 +3602,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
if (properties.getType() == EntityTypes::Image) {
|
if (properties.getType() == EntityTypes::Image) {
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
||||||
|
properties.getPulse().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IMAGE_URL, QString, setImageURL);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IMAGE_URL, QString, setImageURL);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_EMISSIVE, bool, setEmissive);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_EMISSIVE, bool, setEmissive);
|
||||||
|
@ -3561,6 +3615,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
if (properties.getType() == EntityTypes::Grid) {
|
if (properties.getType() == EntityTypes::Grid) {
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_COLOR, u8vec3Color, setColor);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_ALPHA, float, setAlpha);
|
||||||
|
properties.getPulse().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_GRID_FOLLOW_CAMERA, bool, setFollowCamera);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_GRID_FOLLOW_CAMERA, bool, setFollowCamera);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAJOR_GRID_EVERY, uint32_t, setMajorGridEvery);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAJOR_GRID_EVERY, uint32_t, setMajorGridEvery);
|
||||||
|
@ -3764,6 +3819,7 @@ void EntityItemProperties::markAllChanged() {
|
||||||
_shapeTypeChanged = true;
|
_shapeTypeChanged = true;
|
||||||
_colorChanged = true;
|
_colorChanged = true;
|
||||||
_alphaChanged = true;
|
_alphaChanged = true;
|
||||||
|
_pulse.markAllChanged();
|
||||||
_texturesChanged = true;
|
_texturesChanged = true;
|
||||||
_compoundShapeURLChanged = true;
|
_compoundShapeURLChanged = true;
|
||||||
|
|
||||||
|
@ -4228,6 +4284,7 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
||||||
if (alphaChanged()) {
|
if (alphaChanged()) {
|
||||||
out += "alpha";
|
out += "alpha";
|
||||||
}
|
}
|
||||||
|
getPulse().listChangedProperties(out);
|
||||||
if (texturesChanged()) {
|
if (texturesChanged()) {
|
||||||
out += "textures";
|
out += "textures";
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include "SkyboxPropertyGroup.h"
|
#include "SkyboxPropertyGroup.h"
|
||||||
#include "HazePropertyGroup.h"
|
#include "HazePropertyGroup.h"
|
||||||
#include "BloomPropertyGroup.h"
|
#include "BloomPropertyGroup.h"
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
#include "MaterialMappingMode.h"
|
#include "MaterialMappingMode.h"
|
||||||
#include "BillboardMode.h"
|
#include "BillboardMode.h"
|
||||||
|
@ -229,6 +230,7 @@ public:
|
||||||
DEFINE_PROPERTY_REF(PROP_COMPOUND_SHAPE_URL, CompoundShapeURL, compoundShapeURL, QString, "");
|
DEFINE_PROPERTY_REF(PROP_COMPOUND_SHAPE_URL, CompoundShapeURL, compoundShapeURL, QString, "");
|
||||||
DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, u8vec3Color, particle::DEFAULT_COLOR);
|
DEFINE_PROPERTY_REF(PROP_COLOR, Color, color, u8vec3Color, particle::DEFAULT_COLOR);
|
||||||
DEFINE_PROPERTY(PROP_ALPHA, Alpha, alpha, float, particle::DEFAULT_ALPHA);
|
DEFINE_PROPERTY(PROP_ALPHA, Alpha, alpha, float, particle::DEFAULT_ALPHA);
|
||||||
|
DEFINE_PROPERTY_GROUP(Pulse, pulse, PulsePropertyGroup);
|
||||||
DEFINE_PROPERTY_REF(PROP_TEXTURES, Textures, textures, QString, "");
|
DEFINE_PROPERTY_REF(PROP_TEXTURES, Textures, textures, QString, "");
|
||||||
|
|
||||||
// Particles
|
// Particles
|
||||||
|
|
|
@ -383,13 +383,29 @@ inline QRect QRect_convertFromScriptValue(const QScriptValue& v, bool& isValid)
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(P, S) \
|
#define COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(P, S) \
|
||||||
QScriptValue P = object.property(#P); \
|
{ \
|
||||||
if (P.isValid()) { \
|
QScriptValue P = object.property(#P); \
|
||||||
QString newValue = P.toVariant().toString(); \
|
if (P.isValid()) { \
|
||||||
if (_defaultSettings || newValue != get##S##AsString()) { \
|
QString newValue = P.toVariant().toString(); \
|
||||||
set##S##FromString(newValue); \
|
if (_defaultSettings || newValue != get##S##AsString()) { \
|
||||||
} \
|
set##S##FromString(newValue); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE_ENUM(G, P, S) \
|
||||||
|
{ \
|
||||||
|
QScriptValue G = object.property(#G); \
|
||||||
|
if (G.isValid()) { \
|
||||||
|
QScriptValue P = G.property(#P); \
|
||||||
|
if (P.isValid()) { \
|
||||||
|
QString newValue = P.toVariant().toString(); \
|
||||||
|
if (_defaultSettings || newValue != get##S##AsString()) { \
|
||||||
|
set##S##FromString(newValue); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEFINE_PROPERTY_GROUP(N, n, T) \
|
#define DEFINE_PROPERTY_GROUP(N, n, T) \
|
||||||
|
|
|
@ -112,6 +112,11 @@ enum EntityPropertyList {
|
||||||
PROP_COMPOUND_SHAPE_URL,
|
PROP_COMPOUND_SHAPE_URL,
|
||||||
PROP_COLOR,
|
PROP_COLOR,
|
||||||
PROP_ALPHA,
|
PROP_ALPHA,
|
||||||
|
PROP_PULSE_MIN,
|
||||||
|
PROP_PULSE_MAX,
|
||||||
|
PROP_PULSE_PERIOD,
|
||||||
|
PROP_PULSE_COLOR_MODE,
|
||||||
|
PROP_PULSE_ALPHA_MODE,
|
||||||
PROP_TEXTURES,
|
PROP_TEXTURES,
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -35,6 +35,9 @@ EntityItemProperties GridEntityItem::getProperties(const EntityPropertyFlags& de
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.getProperties(properties);
|
||||||
|
});
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(followCamera, getFollowCamera);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(followCamera, getFollowCamera);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(majorGridEvery, getMajorGridEvery);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(majorGridEvery, getMajorGridEvery);
|
||||||
|
@ -48,6 +51,10 @@ bool GridEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
bool pulsePropertiesChanged = _pulseProperties.setProperties(properties);
|
||||||
|
somethingChanged |= pulsePropertiesChanged;
|
||||||
|
});
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(followCamera, setFollowCamera);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(followCamera, setFollowCamera);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(majorGridEvery, setMajorGridEvery);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(majorGridEvery, setMajorGridEvery);
|
||||||
|
@ -76,6 +83,13 @@ int GridEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_COLOR, u8vec3Color, setColor);
|
READ_ENTITY_PROPERTY(PROP_COLOR, u8vec3Color, setColor);
|
||||||
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
int bytesFromPulse = _pulseProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData,
|
||||||
|
somethingChanged);
|
||||||
|
bytesRead += bytesFromPulse;
|
||||||
|
dataAt += bytesFromPulse;
|
||||||
|
});
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_GRID_FOLLOW_CAMERA, bool, setFollowCamera);
|
READ_ENTITY_PROPERTY(PROP_GRID_FOLLOW_CAMERA, bool, setFollowCamera);
|
||||||
READ_ENTITY_PROPERTY(PROP_MAJOR_GRID_EVERY, uint32_t, setMajorGridEvery);
|
READ_ENTITY_PROPERTY(PROP_MAJOR_GRID_EVERY, uint32_t, setMajorGridEvery);
|
||||||
|
@ -89,6 +103,7 @@ EntityPropertyFlags GridEntityItem::getEntityProperties(EncodeBitstreamParams& p
|
||||||
|
|
||||||
requestedProperties += PROP_COLOR;
|
requestedProperties += PROP_COLOR;
|
||||||
requestedProperties += PROP_ALPHA;
|
requestedProperties += PROP_ALPHA;
|
||||||
|
requestedProperties += _pulseProperties.getEntityProperties(params);
|
||||||
|
|
||||||
requestedProperties += PROP_GRID_FOLLOW_CAMERA;
|
requestedProperties += PROP_GRID_FOLLOW_CAMERA;
|
||||||
requestedProperties += PROP_MAJOR_GRID_EVERY;
|
requestedProperties += PROP_MAJOR_GRID_EVERY;
|
||||||
|
@ -98,7 +113,7 @@ EntityPropertyFlags GridEntityItem::getEntityProperties(EncodeBitstreamParams& p
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void GridEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -109,6 +124,10 @@ void GridEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
});
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_GRID_FOLLOW_CAMERA, getFollowCamera());
|
APPEND_ENTITY_PROPERTY(PROP_GRID_FOLLOW_CAMERA, getFollowCamera());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_MAJOR_GRID_EVERY, getMajorGridEvery());
|
APPEND_ENTITY_PROPERTY(PROP_MAJOR_GRID_EVERY, getMajorGridEvery());
|
||||||
|
@ -176,3 +195,9 @@ float GridEntityItem::getMinorGridEvery() const {
|
||||||
return _minorGridEvery;
|
return _minorGridEvery;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulsePropertyGroup GridEntityItem::getPulseProperties() const {
|
||||||
|
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||||
|
return _pulseProperties;
|
||||||
|
});
|
||||||
|
}
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
class GridEntityItem : public EntityItem {
|
class GridEntityItem : public EntityItem {
|
||||||
using Pointer = std::shared_ptr<GridEntityItem>;
|
using Pointer = std::shared_ptr<GridEntityItem>;
|
||||||
public:
|
public:
|
||||||
|
@ -29,7 +31,7 @@ public:
|
||||||
EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||||
|
|
||||||
void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -59,9 +61,13 @@ public:
|
||||||
void setMinorGridEvery(float minorGridEvery);
|
void setMinorGridEvery(float minorGridEvery);
|
||||||
float getMinorGridEvery() const;
|
float getMinorGridEvery() const;
|
||||||
|
|
||||||
|
PulsePropertyGroup getPulseProperties() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
glm::u8vec3 _color;
|
glm::u8vec3 _color;
|
||||||
float _alpha;
|
float _alpha;
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
|
|
||||||
bool _followCamera { true };
|
bool _followCamera { true };
|
||||||
uint32_t _majorGridEvery { DEFAULT_MAJOR_GRID_EVERY };
|
uint32_t _majorGridEvery { DEFAULT_MAJOR_GRID_EVERY };
|
||||||
float _minorGridEvery { DEFAULT_MINOR_GRID_EVERY };
|
float _minorGridEvery { DEFAULT_MINOR_GRID_EVERY };
|
||||||
|
|
|
@ -32,6 +32,9 @@ EntityItemProperties ImageEntityItem::getProperties(const EntityPropertyFlags& d
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.getProperties(properties);
|
||||||
|
});
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(imageURL, getImageURL);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(imageURL, getImageURL);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(emissive, getEmissive);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(emissive, getEmissive);
|
||||||
|
@ -47,6 +50,10 @@ bool ImageEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
bool pulsePropertiesChanged = _pulseProperties.setProperties(properties);
|
||||||
|
somethingChanged |= pulsePropertiesChanged;
|
||||||
|
});
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(imageURL, setImageURL);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(imageURL, setImageURL);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(emissive, setEmissive);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(emissive, setEmissive);
|
||||||
|
@ -77,6 +84,13 @@ int ImageEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_COLOR, u8vec3Color, setColor);
|
READ_ENTITY_PROPERTY(PROP_COLOR, u8vec3Color, setColor);
|
||||||
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
int bytesFromPulse = _pulseProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData,
|
||||||
|
somethingChanged);
|
||||||
|
bytesRead += bytesFromPulse;
|
||||||
|
dataAt += bytesFromPulse;
|
||||||
|
});
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_IMAGE_URL, QString, setImageURL);
|
READ_ENTITY_PROPERTY(PROP_IMAGE_URL, QString, setImageURL);
|
||||||
READ_ENTITY_PROPERTY(PROP_EMISSIVE, bool, setEmissive);
|
READ_ENTITY_PROPERTY(PROP_EMISSIVE, bool, setEmissive);
|
||||||
|
@ -92,6 +106,7 @@ EntityPropertyFlags ImageEntityItem::getEntityProperties(EncodeBitstreamParams&
|
||||||
|
|
||||||
requestedProperties += PROP_COLOR;
|
requestedProperties += PROP_COLOR;
|
||||||
requestedProperties += PROP_ALPHA;
|
requestedProperties += PROP_ALPHA;
|
||||||
|
requestedProperties += _pulseProperties.getEntityProperties(params);
|
||||||
|
|
||||||
requestedProperties += PROP_IMAGE_URL;
|
requestedProperties += PROP_IMAGE_URL;
|
||||||
requestedProperties += PROP_EMISSIVE;
|
requestedProperties += PROP_EMISSIVE;
|
||||||
|
@ -103,7 +118,7 @@ EntityPropertyFlags ImageEntityItem::getEntityProperties(EncodeBitstreamParams&
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void ImageEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -114,6 +129,10 @@ void ImageEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
});
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_IMAGE_URL, getImageURL());
|
APPEND_ENTITY_PROPERTY(PROP_IMAGE_URL, getImageURL());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_EMISSIVE, getEmissive());
|
APPEND_ENTITY_PROPERTY(PROP_EMISSIVE, getEmissive());
|
||||||
|
@ -267,3 +286,9 @@ float ImageEntityItem::getAlpha() const {
|
||||||
return _alpha;
|
return _alpha;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulsePropertyGroup ImageEntityItem::getPulseProperties() const {
|
||||||
|
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||||
|
return _pulseProperties;
|
||||||
|
});
|
||||||
|
}
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
class ImageEntityItem : public EntityItem {
|
class ImageEntityItem : public EntityItem {
|
||||||
using Pointer = std::shared_ptr<ImageEntityItem>;
|
using Pointer = std::shared_ptr<ImageEntityItem>;
|
||||||
public:
|
public:
|
||||||
|
@ -29,7 +31,7 @@ public:
|
||||||
EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||||
|
|
||||||
void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -72,6 +74,8 @@ public:
|
||||||
void setAlpha(float alpha);
|
void setAlpha(float alpha);
|
||||||
float getAlpha() const;
|
float getAlpha() const;
|
||||||
|
|
||||||
|
PulsePropertyGroup getPulseProperties() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString _imageURL;
|
QString _imageURL;
|
||||||
bool _emissive { false };
|
bool _emissive { false };
|
||||||
|
@ -81,6 +85,7 @@ protected:
|
||||||
|
|
||||||
glm::u8vec3 _color;
|
glm::u8vec3 _color;
|
||||||
float _alpha;
|
float _alpha;
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ImageEntityItem_h
|
#endif // hifi_ImageEntityItem_h
|
||||||
|
|
|
@ -412,6 +412,9 @@ EntityItemProperties ParticleEffectEntityItem::getProperties(const EntityPropert
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(shapeType, getShapeType);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.getProperties(properties);
|
||||||
|
});
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(textures, getTextures);
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxParticles, getMaxParticles);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxParticles, getMaxParticles);
|
||||||
|
@ -463,6 +466,10 @@ bool ParticleEffectEntityItem::setProperties(const EntityItemProperties& propert
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shapeType, setShapeType);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
bool pulsePropertiesChanged = _pulseProperties.setProperties(properties);
|
||||||
|
somethingChanged |= pulsePropertiesChanged;
|
||||||
|
});
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textures, setTextures);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textures, setTextures);
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(maxParticles, setMaxParticles);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(maxParticles, setMaxParticles);
|
||||||
|
@ -535,6 +542,13 @@ int ParticleEffectEntityItem::readEntitySubclassDataFromBuffer(const unsigned ch
|
||||||
READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, setShapeType);
|
READ_ENTITY_PROPERTY(PROP_SHAPE_TYPE, ShapeType, setShapeType);
|
||||||
READ_ENTITY_PROPERTY(PROP_COLOR, u8vec3Color, setColor);
|
READ_ENTITY_PROPERTY(PROP_COLOR, u8vec3Color, setColor);
|
||||||
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
int bytesFromPulse = _pulseProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData,
|
||||||
|
somethingChanged);
|
||||||
|
bytesRead += bytesFromPulse;
|
||||||
|
dataAt += bytesFromPulse;
|
||||||
|
});
|
||||||
READ_ENTITY_PROPERTY(PROP_TEXTURES, QString, setTextures);
|
READ_ENTITY_PROPERTY(PROP_TEXTURES, QString, setTextures);
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_MAX_PARTICLES, quint32, setMaxParticles);
|
READ_ENTITY_PROPERTY(PROP_MAX_PARTICLES, quint32, setMaxParticles);
|
||||||
|
@ -586,6 +600,7 @@ EntityPropertyFlags ParticleEffectEntityItem::getEntityProperties(EncodeBitstrea
|
||||||
requestedProperties += PROP_SHAPE_TYPE;
|
requestedProperties += PROP_SHAPE_TYPE;
|
||||||
requestedProperties += PROP_COLOR;
|
requestedProperties += PROP_COLOR;
|
||||||
requestedProperties += PROP_ALPHA;
|
requestedProperties += PROP_ALPHA;
|
||||||
|
requestedProperties += _pulseProperties.getEntityProperties(params);
|
||||||
requestedProperties += PROP_TEXTURES;
|
requestedProperties += PROP_TEXTURES;
|
||||||
|
|
||||||
requestedProperties += PROP_MAX_PARTICLES;
|
requestedProperties += PROP_MAX_PARTICLES;
|
||||||
|
@ -643,6 +658,10 @@ void ParticleEffectEntityItem::appendSubclassData(OctreePacketData* packetData,
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType());
|
APPEND_ENTITY_PROPERTY(PROP_SHAPE_TYPE, (uint32_t)getShapeType());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
});
|
||||||
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, getTextures());
|
APPEND_ENTITY_PROPERTY(PROP_TEXTURES, getTextures());
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_MAX_PARTICLES, getMaxParticles());
|
APPEND_ENTITY_PROPERTY(PROP_MAX_PARTICLES, getMaxParticles());
|
||||||
|
@ -787,3 +806,9 @@ particle::Properties ParticleEffectEntityItem::getParticleProperties() const {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulsePropertyGroup ParticleEffectEntityItem::getPulseProperties() const {
|
||||||
|
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||||
|
return _pulseProperties;
|
||||||
|
});
|
||||||
|
}
|
|
@ -16,6 +16,7 @@
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
#include "ColorUtils.h"
|
#include "ColorUtils.h"
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
namespace particle {
|
namespace particle {
|
||||||
static const float SCRIPT_MAXIMUM_PI = 3.1416f; // Round up so that reasonable property values work
|
static const float SCRIPT_MAXIMUM_PI = 3.1416f; // Round up so that reasonable property values work
|
||||||
|
@ -341,9 +342,11 @@ public:
|
||||||
virtual bool supportsDetailedIntersection() const override { return false; }
|
virtual bool supportsDetailedIntersection() const override { return false; }
|
||||||
|
|
||||||
particle::Properties getParticleProperties() const;
|
particle::Properties getParticleProperties() const;
|
||||||
|
PulsePropertyGroup getPulseProperties() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
particle::Properties _particleProperties;
|
particle::Properties _particleProperties;
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
bool _isEmitting { true };
|
bool _isEmitting { true };
|
||||||
|
|
||||||
ShapeType _shapeType { SHAPE_TYPE_NONE };
|
ShapeType _shapeType { SHAPE_TYPE_NONE };
|
||||||
|
|
249
libraries/entities/src/PulsePropertyGroup.cpp
Normal file
249
libraries/entities/src/PulsePropertyGroup.cpp
Normal file
|
@ -0,0 +1,249 @@
|
||||||
|
//
|
||||||
|
// PulsePropertyGroup.cpp
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 1/15/19
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
|
#include <OctreePacketData.h>
|
||||||
|
|
||||||
|
#include "EntityItemProperties.h"
|
||||||
|
#include "EntityItemPropertiesMacros.h"
|
||||||
|
|
||||||
|
QHash<QString, PulseMode> stringToPulseModeLookup;
|
||||||
|
|
||||||
|
void addPulseMode(PulseMode mode) {
|
||||||
|
stringToPulseModeLookup[PulseModeHelpers::getNameForPulseMode(mode)] = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildStringToPulseModeLookup() {
|
||||||
|
addPulseMode(PulseMode::NONE);
|
||||||
|
addPulseMode(PulseMode::IN_PHASE);
|
||||||
|
addPulseMode(PulseMode::OUT_PHASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PulsePropertyGroup::getColorModeAsString() const {
|
||||||
|
return PulseModeHelpers::getNameForPulseMode(_colorMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::setColorModeFromString(const QString& pulseMode) {
|
||||||
|
if (stringToPulseModeLookup.empty()) {
|
||||||
|
buildStringToPulseModeLookup();
|
||||||
|
}
|
||||||
|
auto pulseModeItr = stringToPulseModeLookup.find(pulseMode.toLower());
|
||||||
|
if (pulseModeItr != stringToPulseModeLookup.end()) {
|
||||||
|
_colorMode = pulseModeItr.value();
|
||||||
|
_colorModeChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString PulsePropertyGroup::getAlphaModeAsString() const {
|
||||||
|
return PulseModeHelpers::getNameForPulseMode(_alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::setAlphaModeFromString(const QString& pulseMode) {
|
||||||
|
if (stringToPulseModeLookup.empty()) {
|
||||||
|
buildStringToPulseModeLookup();
|
||||||
|
}
|
||||||
|
auto pulseModeItr = stringToPulseModeLookup.find(pulseMode.toLower());
|
||||||
|
if (pulseModeItr != stringToPulseModeLookup.end()) {
|
||||||
|
_alphaMode = pulseModeItr.value();
|
||||||
|
_alphaModeChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties,
|
||||||
|
QScriptEngine* engine, bool skipDefaults,
|
||||||
|
EntityItemProperties& defaultEntityProperties) const {
|
||||||
|
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_PULSE_MIN, Pulse, pulse, Min, min);
|
||||||
|
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_PULSE_MAX, Pulse, pulse, Max, max);
|
||||||
|
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE(PROP_PULSE_PERIOD, Pulse, pulse, Period, period);
|
||||||
|
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_PULSE_COLOR_MODE, Pulse, pulse, ColorMode, colorMode, getColorModeAsString);
|
||||||
|
COPY_GROUP_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_PULSE_ALPHA_MODE, Pulse, pulse, AlphaMode, alphaMode, getAlphaModeAsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) {
|
||||||
|
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(pulse, min, float, setMin);
|
||||||
|
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(pulse, max, float, setMax);
|
||||||
|
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE(pulse, period, float, setPeriod);
|
||||||
|
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE_ENUM(pulse, colorMode, ColorMode);
|
||||||
|
COPY_GROUP_PROPERTY_FROM_QSCRIPTVALUE_ENUM(pulse, alphaMode, AlphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::merge(const PulsePropertyGroup& other) {
|
||||||
|
COPY_PROPERTY_IF_CHANGED(min);
|
||||||
|
COPY_PROPERTY_IF_CHANGED(max);
|
||||||
|
COPY_PROPERTY_IF_CHANGED(period);
|
||||||
|
COPY_PROPERTY_IF_CHANGED(colorMode);
|
||||||
|
COPY_PROPERTY_IF_CHANGED(alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::debugDump() const {
|
||||||
|
qCDebug(entities) << " PulsePropertyGroup: ---------------------------------------------";
|
||||||
|
qCDebug(entities) << " _min:" << _min;
|
||||||
|
qCDebug(entities) << " _max:" << _max;
|
||||||
|
qCDebug(entities) << " _period:" << _period;
|
||||||
|
qCDebug(entities) << " _colorMode:" << getColorModeAsString();
|
||||||
|
qCDebug(entities) << " _alphaMode:" << getAlphaModeAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::listChangedProperties(QList<QString>& out) {
|
||||||
|
if (minChanged()) {
|
||||||
|
out << "pulse-min";
|
||||||
|
}
|
||||||
|
if (maxChanged()) {
|
||||||
|
out << "pulse-max";
|
||||||
|
}
|
||||||
|
if (periodChanged()) {
|
||||||
|
out << "pulse-period";
|
||||||
|
}
|
||||||
|
if (colorModeChanged()) {
|
||||||
|
out << "pulse-colorMode";
|
||||||
|
}
|
||||||
|
if (alphaModeChanged()) {
|
||||||
|
out << "pulse-alphaMode";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PulsePropertyGroup::appendToEditPacket(OctreePacketData* packetData,
|
||||||
|
EntityPropertyFlags& requestedProperties,
|
||||||
|
EntityPropertyFlags& propertyFlags,
|
||||||
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
int& propertyCount,
|
||||||
|
OctreeElement::AppendState& appendState) const {
|
||||||
|
|
||||||
|
bool successPropertyFits = true;
|
||||||
|
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_MIN, getMin());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_MAX, getMax());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_PERIOD, getPeriod());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_COLOR_MODE, (uint32_t)getColorMode());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_ALPHA_MODE, (uint32_t)getAlphaMode());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PulsePropertyGroup::decodeFromEditPacket(EntityPropertyFlags& propertyFlags,
|
||||||
|
const unsigned char*& dataAt , int& processedBytes) {
|
||||||
|
|
||||||
|
int bytesRead = 0;
|
||||||
|
bool overwriteLocalData = true;
|
||||||
|
bool somethingChanged = false;
|
||||||
|
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_MIN, float, setMin);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_MAX, float, setMax);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_PERIOD, float, setPeriod);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_COLOR_MODE, PulseMode, setColorMode);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_ALPHA_MODE, PulseMode, setAlphaMode);
|
||||||
|
|
||||||
|
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_PULSE_MIN, Min);
|
||||||
|
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_PULSE_MAX, Max);
|
||||||
|
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_PULSE_PERIOD, Period);
|
||||||
|
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_PULSE_COLOR_MODE, ColorMode);
|
||||||
|
DECODE_GROUP_PROPERTY_HAS_CHANGED(PROP_PULSE_ALPHA_MODE, AlphaMode);
|
||||||
|
|
||||||
|
processedBytes += bytesRead;
|
||||||
|
|
||||||
|
Q_UNUSED(somethingChanged);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::markAllChanged() {
|
||||||
|
_minChanged = true;
|
||||||
|
_maxChanged = true;
|
||||||
|
_periodChanged = true;
|
||||||
|
_colorModeChanged = true;
|
||||||
|
_alphaModeChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityPropertyFlags PulsePropertyGroup::getChangedProperties() const {
|
||||||
|
EntityPropertyFlags changedProperties;
|
||||||
|
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_PULSE_MIN, min);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_PULSE_MAX, max);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_PULSE_PERIOD, period);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_PULSE_COLOR_MODE, colorMode);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_PULSE_ALPHA_MODE, alphaMode);
|
||||||
|
|
||||||
|
return changedProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::getProperties(EntityItemProperties& properties) const {
|
||||||
|
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Pulse, Min, getMin);
|
||||||
|
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Pulse, Max, getMax);
|
||||||
|
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Pulse, Period, getPeriod);
|
||||||
|
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Pulse, ColorMode, getColorMode);
|
||||||
|
COPY_ENTITY_GROUP_PROPERTY_TO_PROPERTIES(Pulse, AlphaMode, getAlphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PulsePropertyGroup::setProperties(const EntityItemProperties& properties) {
|
||||||
|
bool somethingChanged = false;
|
||||||
|
|
||||||
|
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Pulse, Min, min, setMin);
|
||||||
|
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Pulse, Max, max, setMax);
|
||||||
|
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Pulse, Period, period, setPeriod);
|
||||||
|
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Pulse, ColorMode, colorMode, setColorMode);
|
||||||
|
SET_ENTITY_GROUP_PROPERTY_FROM_PROPERTIES(Pulse, AlphaMode, alphaMode, setAlphaMode);
|
||||||
|
|
||||||
|
return somethingChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityPropertyFlags PulsePropertyGroup::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||||
|
EntityPropertyFlags requestedProperties;
|
||||||
|
|
||||||
|
requestedProperties += PROP_PULSE_MIN;
|
||||||
|
requestedProperties += PROP_PULSE_MAX;
|
||||||
|
requestedProperties += PROP_PULSE_PERIOD;
|
||||||
|
requestedProperties += PROP_PULSE_COLOR_MODE;
|
||||||
|
requestedProperties += PROP_PULSE_ALPHA_MODE;
|
||||||
|
|
||||||
|
return requestedProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PulsePropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
|
EntityPropertyFlags& requestedProperties,
|
||||||
|
EntityPropertyFlags& propertyFlags,
|
||||||
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
int& propertyCount,
|
||||||
|
OctreeElement::AppendState& appendState) const {
|
||||||
|
|
||||||
|
bool successPropertyFits = true;
|
||||||
|
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_MIN, getMin());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_MAX, getMax());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_PERIOD, getPeriod());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_COLOR_MODE, (uint32_t)getColorMode());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_PULSE_ALPHA_MODE, (uint32_t)getAlphaMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
int PulsePropertyGroup::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||||
|
ReadBitstreamToTreeParams& args,
|
||||||
|
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||||
|
bool& somethingChanged) {
|
||||||
|
|
||||||
|
int bytesRead = 0;
|
||||||
|
const unsigned char* dataAt = data;
|
||||||
|
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_MIN, float, setMin);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_MAX, float, setMax);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_PERIOD, float, setPeriod);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_COLOR_MODE, PulseMode, setColorMode);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_PULSE_ALPHA_MODE, PulseMode, setAlphaMode);
|
||||||
|
|
||||||
|
return bytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PulsePropertyGroup::operator==(const PulsePropertyGroup& a) const {
|
||||||
|
return (a._min == _min) &&
|
||||||
|
(a._max == _max) &&
|
||||||
|
(a._period == _period) &&
|
||||||
|
(a._colorMode == _colorMode) &&
|
||||||
|
(a._alphaMode == _alphaMode);
|
||||||
|
}
|
99
libraries/entities/src/PulsePropertyGroup.h
Normal file
99
libraries/entities/src/PulsePropertyGroup.h
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
//
|
||||||
|
// PulsePropertyGroup.h
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 1/15/19
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_PulsePropertyGroup_h
|
||||||
|
#define hifi_PulsePropertyGroup_h
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <QtScript/QScriptEngine>
|
||||||
|
|
||||||
|
#include <PulseMode.h>
|
||||||
|
|
||||||
|
#include "PropertyGroup.h"
|
||||||
|
#include "EntityItemPropertiesMacros.h"
|
||||||
|
|
||||||
|
class EntityItemProperties;
|
||||||
|
class EncodeBitstreamParams;
|
||||||
|
class OctreePacketData;
|
||||||
|
class ReadBitstreamToTreeParams;
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Pulse is defined by the following properties.
|
||||||
|
* @typedef {object} Entities.Pulse
|
||||||
|
*
|
||||||
|
* @property {number} min=0 - The minimum value of the pulse multiplier.
|
||||||
|
* @property {number} max=1 - The maximum value of the pulse multiplier.
|
||||||
|
* @property {number} period=1 - The duration of the color and alpha pulse, in seconds. A pulse multiplier value goes from
|
||||||
|
* <code>min</code> to <code>max</code>, then <code>max</code> to <code>min</code> in one period.
|
||||||
|
* @property {PulseMode} colorMode="none" - If "in", the color is pulsed in phase with the pulse period; if "out"
|
||||||
|
* the color is pulsed out of phase with the pulse period.
|
||||||
|
* @property {PulseMode} alphaMode="none" - If "in", the alpha is pulsed in phase with the pulse period; if "out"
|
||||||
|
* the alpha is pulsed out of phase with the pulse period.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PulsePropertyGroup : public PropertyGroup {
|
||||||
|
public:
|
||||||
|
// EntityItemProperty related helpers
|
||||||
|
virtual void copyToScriptValue(const EntityPropertyFlags& desiredProperties, QScriptValue& properties,
|
||||||
|
QScriptEngine* engine, bool skipDefaults,
|
||||||
|
EntityItemProperties& defaultEntityProperties) const override;
|
||||||
|
virtual void copyFromScriptValue(const QScriptValue& object, bool& _defaultSettings) override;
|
||||||
|
|
||||||
|
void merge(const PulsePropertyGroup& other);
|
||||||
|
|
||||||
|
virtual void debugDump() const override;
|
||||||
|
virtual void listChangedProperties(QList<QString>& out) override;
|
||||||
|
|
||||||
|
virtual bool appendToEditPacket(OctreePacketData* packetData,
|
||||||
|
EntityPropertyFlags& requestedProperties,
|
||||||
|
EntityPropertyFlags& propertyFlags,
|
||||||
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
int& propertyCount,
|
||||||
|
OctreeElement::AppendState& appendState) const override;
|
||||||
|
|
||||||
|
virtual bool decodeFromEditPacket(EntityPropertyFlags& propertyFlags,
|
||||||
|
const unsigned char*& dataAt, int& processedBytes) override;
|
||||||
|
virtual void markAllChanged() override;
|
||||||
|
virtual EntityPropertyFlags getChangedProperties() const override;
|
||||||
|
|
||||||
|
// EntityItem related helpers
|
||||||
|
// methods for getting/setting all properties of an entity
|
||||||
|
virtual void getProperties(EntityItemProperties& propertiesOut) const override;
|
||||||
|
|
||||||
|
// returns true if something changed
|
||||||
|
virtual bool setProperties(const EntityItemProperties& properties) override;
|
||||||
|
|
||||||
|
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||||
|
|
||||||
|
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
|
EntityPropertyFlags& requestedProperties,
|
||||||
|
EntityPropertyFlags& propertyFlags,
|
||||||
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
int& propertyCount,
|
||||||
|
OctreeElement::AppendState& appendState) const override;
|
||||||
|
|
||||||
|
virtual int readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||||
|
ReadBitstreamToTreeParams& args,
|
||||||
|
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||||
|
bool& somethingChanged) override;
|
||||||
|
|
||||||
|
bool operator==(const PulsePropertyGroup& a) const;
|
||||||
|
bool operator!=(const PulsePropertyGroup& a) const { return !(*this == a); }
|
||||||
|
|
||||||
|
DEFINE_PROPERTY(PROP_PULSE_MIN, Min, min, float, 0.0f);
|
||||||
|
DEFINE_PROPERTY(PROP_PULSE_MAX, Max, max, float, 1.0f);
|
||||||
|
DEFINE_PROPERTY(PROP_PULSE_PERIOD, Period, period, float, 1.0f);
|
||||||
|
DEFINE_PROPERTY_REF_ENUM(PROP_PULSE_COLOR_MODE, ColorMode, colorMode, PulseMode, PulseMode::NONE);
|
||||||
|
DEFINE_PROPERTY_REF_ENUM(PROP_PULSE_ALPHA_MODE, AlphaMode, alphaMode, PulseMode, PulseMode::NONE);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_PulsePropertyGroup_h
|
|
@ -120,6 +120,9 @@ EntityItemProperties ShapeEntityItem::getProperties(const EntityPropertyFlags& d
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.getProperties(properties);
|
||||||
|
});
|
||||||
properties.setShape(entity::stringFromShape(getShape()));
|
properties.setShape(entity::stringFromShape(getShape()));
|
||||||
properties._shapeChanged = false;
|
properties._shapeChanged = false;
|
||||||
|
|
||||||
|
@ -160,6 +163,10 @@ bool ShapeEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
bool pulsePropertiesChanged = _pulseProperties.setProperties(properties);
|
||||||
|
somethingChanged |= pulsePropertiesChanged;
|
||||||
|
});
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shape, setShape);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(shape, setShape);
|
||||||
|
|
||||||
if (somethingChanged) {
|
if (somethingChanged) {
|
||||||
|
@ -185,6 +192,13 @@ int ShapeEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_COLOR, glm::u8vec3, setColor);
|
READ_ENTITY_PROPERTY(PROP_COLOR, glm::u8vec3, setColor);
|
||||||
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
int bytesFromPulse = _pulseProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData,
|
||||||
|
somethingChanged);
|
||||||
|
bytesRead += bytesFromPulse;
|
||||||
|
dataAt += bytesFromPulse;
|
||||||
|
});
|
||||||
READ_ENTITY_PROPERTY(PROP_SHAPE, QString, setShape);
|
READ_ENTITY_PROPERTY(PROP_SHAPE, QString, setShape);
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
|
@ -194,12 +208,13 @@ EntityPropertyFlags ShapeEntityItem::getEntityProperties(EncodeBitstreamParams&
|
||||||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||||
requestedProperties += PROP_COLOR;
|
requestedProperties += PROP_COLOR;
|
||||||
requestedProperties += PROP_ALPHA;
|
requestedProperties += PROP_ALPHA;
|
||||||
|
requestedProperties += _pulseProperties.getEntityProperties(params);
|
||||||
requestedProperties += PROP_SHAPE;
|
requestedProperties += PROP_SHAPE;
|
||||||
return requestedProperties;
|
return requestedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShapeEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void ShapeEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -209,6 +224,10 @@ void ShapeEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBit
|
||||||
bool successPropertyFits = true;
|
bool successPropertyFits = true;
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
});
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SHAPE, entity::stringFromShape(getShape()));
|
APPEND_ENTITY_PROPERTY(PROP_SHAPE, entity::stringFromShape(getShape()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,3 +439,9 @@ void ShapeEntityItem::computeShapeInfo(ShapeInfo& info) {
|
||||||
ShapeType ShapeEntityItem::getShapeType() const {
|
ShapeType ShapeEntityItem::getShapeType() const {
|
||||||
return _collisionShapeType;
|
return _collisionShapeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulsePropertyGroup ShapeEntityItem::getPulseProperties() const {
|
||||||
|
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||||
|
return _pulseProperties;
|
||||||
|
});
|
||||||
|
}
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
namespace entity {
|
namespace entity {
|
||||||
enum Shape {
|
enum Shape {
|
||||||
Triangle,
|
Triangle,
|
||||||
|
@ -58,7 +60,7 @@ public:
|
||||||
EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||||
|
|
||||||
void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -101,9 +103,12 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<graphics::Material> getMaterial() { return _material; }
|
std::shared_ptr<graphics::Material> getMaterial() { return _material; }
|
||||||
|
|
||||||
|
PulsePropertyGroup getPulseProperties() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
glm::u8vec3 _color;
|
glm::u8vec3 _color;
|
||||||
float _alpha { 1.0f };
|
float _alpha { 1.0f };
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
entity::Shape _shape { entity::Shape::Sphere };
|
entity::Shape _shape { entity::Shape::Sphere };
|
||||||
|
|
||||||
//! This is SHAPE_TYPE_ELLIPSOID rather than SHAPE_TYPE_NONE to maintain
|
//! This is SHAPE_TYPE_ELLIPSOID rather than SHAPE_TYPE_NONE to maintain
|
||||||
|
|
|
@ -49,6 +49,10 @@ void TextEntityItem::setUnscaledDimensions(const glm::vec3& value) {
|
||||||
EntityItemProperties TextEntityItem::getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const {
|
EntityItemProperties TextEntityItem::getProperties(const EntityPropertyFlags& desiredProperties, bool allowEmptyDesiredProperties) const {
|
||||||
EntityItemProperties properties = EntityItem::getProperties(desiredProperties, allowEmptyDesiredProperties); // get the properties from our base class
|
EntityItemProperties properties = EntityItem::getProperties(desiredProperties, allowEmptyDesiredProperties); // get the properties from our base class
|
||||||
|
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.getProperties(properties);
|
||||||
|
});
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(text, getText);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(text, getText);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(lineHeight, getLineHeight);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(lineHeight, getLineHeight);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(textColor, getTextColor);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(textColor, getTextColor);
|
||||||
|
@ -67,6 +71,11 @@ bool TextEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
bool somethingChanged = false;
|
bool somethingChanged = false;
|
||||||
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
somethingChanged = EntityItem::setProperties(properties); // set the properties in our base class
|
||||||
|
|
||||||
|
withWriteLock([&] {
|
||||||
|
bool pulsePropertiesChanged = _pulseProperties.setProperties(properties);
|
||||||
|
somethingChanged |= pulsePropertiesChanged;
|
||||||
|
});
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(text, setText);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(text, setText);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lineHeight, setLineHeight);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lineHeight, setLineHeight);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textColor, setTextColor);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(textColor, setTextColor);
|
||||||
|
@ -101,6 +110,14 @@ int TextEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
const unsigned char* dataAt = data;
|
const unsigned char* dataAt = data;
|
||||||
|
|
||||||
|
withWriteLock([&] {
|
||||||
|
int bytesFromPulse = _pulseProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData,
|
||||||
|
somethingChanged);
|
||||||
|
bytesRead += bytesFromPulse;
|
||||||
|
dataAt += bytesFromPulse;
|
||||||
|
});
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_TEXT, QString, setText);
|
READ_ENTITY_PROPERTY(PROP_TEXT, QString, setText);
|
||||||
READ_ENTITY_PROPERTY(PROP_LINE_HEIGHT, float, setLineHeight);
|
READ_ENTITY_PROPERTY(PROP_LINE_HEIGHT, float, setLineHeight);
|
||||||
READ_ENTITY_PROPERTY(PROP_TEXT_COLOR, glm::u8vec3, setTextColor);
|
READ_ENTITY_PROPERTY(PROP_TEXT_COLOR, glm::u8vec3, setTextColor);
|
||||||
|
@ -118,6 +135,8 @@ int TextEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
||||||
|
|
||||||
EntityPropertyFlags TextEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
EntityPropertyFlags TextEntityItem::getEntityProperties(EncodeBitstreamParams& params) const {
|
||||||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||||
|
|
||||||
|
requestedProperties += _pulseProperties.getEntityProperties(params);
|
||||||
requestedProperties += PROP_TEXT;
|
requestedProperties += PROP_TEXT;
|
||||||
requestedProperties += PROP_LINE_HEIGHT;
|
requestedProperties += PROP_LINE_HEIGHT;
|
||||||
requestedProperties += PROP_TEXT_COLOR;
|
requestedProperties += PROP_TEXT_COLOR;
|
||||||
|
@ -129,11 +148,12 @@ EntityPropertyFlags TextEntityItem::getEntityProperties(EncodeBitstreamParams& p
|
||||||
requestedProperties += PROP_RIGHT_MARGIN;
|
requestedProperties += PROP_RIGHT_MARGIN;
|
||||||
requestedProperties += PROP_TOP_MARGIN;
|
requestedProperties += PROP_TOP_MARGIN;
|
||||||
requestedProperties += PROP_BOTTOM_MARGIN;
|
requestedProperties += PROP_BOTTOM_MARGIN;
|
||||||
|
|
||||||
return requestedProperties;
|
return requestedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void TextEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -142,6 +162,11 @@ void TextEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBits
|
||||||
|
|
||||||
bool successPropertyFits = true;
|
bool successPropertyFits = true;
|
||||||
|
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
});
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_TEXT, getText());
|
APPEND_ENTITY_PROPERTY(PROP_TEXT, getText());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_LINE_HEIGHT, getLineHeight());
|
APPEND_ENTITY_PROPERTY(PROP_LINE_HEIGHT, getLineHeight());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_TEXT_COLOR, getTextColor());
|
APPEND_ENTITY_PROPERTY(PROP_TEXT_COLOR, getTextColor());
|
||||||
|
@ -345,3 +370,9 @@ float TextEntityItem::getBottomMargin() const {
|
||||||
return _bottomMargin;
|
return _bottomMargin;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulsePropertyGroup TextEntityItem::getPulseProperties() const {
|
||||||
|
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||||
|
return _pulseProperties;
|
||||||
|
});
|
||||||
|
}
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
class TextEntityItem : public EntityItem {
|
class TextEntityItem : public EntityItem {
|
||||||
public:
|
public:
|
||||||
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
@ -33,7 +35,7 @@ public:
|
||||||
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||||
|
|
||||||
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -94,6 +96,8 @@ public:
|
||||||
float getBottomMargin() const;
|
float getBottomMargin() const;
|
||||||
void setBottomMargin(float value);
|
void setBottomMargin(float value);
|
||||||
|
|
||||||
|
PulsePropertyGroup getPulseProperties() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _text;
|
QString _text;
|
||||||
float _lineHeight;
|
float _lineHeight;
|
||||||
|
@ -101,6 +105,7 @@ private:
|
||||||
float _textAlpha;
|
float _textAlpha;
|
||||||
glm::u8vec3 _backgroundColor;
|
glm::u8vec3 _backgroundColor;
|
||||||
float _backgroundAlpha;
|
float _backgroundAlpha;
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
BillboardMode _billboardMode;
|
BillboardMode _billboardMode;
|
||||||
float _leftMargin;
|
float _leftMargin;
|
||||||
float _rightMargin;
|
float _rightMargin;
|
||||||
|
|
|
@ -45,6 +45,9 @@ EntityItemProperties WebEntityItem::getProperties(const EntityPropertyFlags& des
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(color, getColor);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(alpha, getAlpha);
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.getProperties(properties);
|
||||||
|
});
|
||||||
|
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(sourceUrl, getSourceUrl);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(sourceUrl, getSourceUrl);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(dpi, getDPI);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(dpi, getDPI);
|
||||||
|
@ -60,6 +63,10 @@ bool WebEntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(color, setColor);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(alpha, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
bool pulsePropertiesChanged = _pulseProperties.setProperties(properties);
|
||||||
|
somethingChanged |= pulsePropertiesChanged;
|
||||||
|
});
|
||||||
|
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(sourceUrl, setSourceUrl);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(sourceUrl, setSourceUrl);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(dpi, setDPI);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(dpi, setDPI);
|
||||||
|
@ -91,6 +98,13 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_COLOR, glm::u8vec3, setColor);
|
READ_ENTITY_PROPERTY(PROP_COLOR, glm::u8vec3, setColor);
|
||||||
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
READ_ENTITY_PROPERTY(PROP_ALPHA, float, setAlpha);
|
||||||
|
withWriteLock([&] {
|
||||||
|
int bytesFromPulse = _pulseProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
|
propertyFlags, overwriteLocalData,
|
||||||
|
somethingChanged);
|
||||||
|
bytesRead += bytesFromPulse;
|
||||||
|
dataAt += bytesFromPulse;
|
||||||
|
});
|
||||||
|
|
||||||
READ_ENTITY_PROPERTY(PROP_SOURCE_URL, QString, setSourceUrl);
|
READ_ENTITY_PROPERTY(PROP_SOURCE_URL, QString, setSourceUrl);
|
||||||
READ_ENTITY_PROPERTY(PROP_DPI, uint16_t, setDPI);
|
READ_ENTITY_PROPERTY(PROP_DPI, uint16_t, setDPI);
|
||||||
|
@ -105,6 +119,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa
|
||||||
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
EntityPropertyFlags requestedProperties = EntityItem::getEntityProperties(params);
|
||||||
requestedProperties += PROP_COLOR;
|
requestedProperties += PROP_COLOR;
|
||||||
requestedProperties += PROP_ALPHA;
|
requestedProperties += PROP_ALPHA;
|
||||||
|
requestedProperties += _pulseProperties.getEntityProperties(params);
|
||||||
|
|
||||||
requestedProperties += PROP_SOURCE_URL;
|
requestedProperties += PROP_SOURCE_URL;
|
||||||
requestedProperties += PROP_DPI;
|
requestedProperties += PROP_DPI;
|
||||||
|
@ -115,7 +130,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -125,6 +140,10 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
|
||||||
bool successPropertyFits = true;
|
bool successPropertyFits = true;
|
||||||
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
APPEND_ENTITY_PROPERTY(PROP_COLOR, getColor());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
APPEND_ENTITY_PROPERTY(PROP_ALPHA, getAlpha());
|
||||||
|
withReadLock([&] {
|
||||||
|
_pulseProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
});
|
||||||
|
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, getSourceUrl());
|
APPEND_ENTITY_PROPERTY(PROP_SOURCE_URL, getSourceUrl());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_DPI, getDPI());
|
APPEND_ENTITY_PROPERTY(PROP_DPI, getDPI());
|
||||||
|
@ -286,3 +305,9 @@ WebInputMode WebEntityItem::getInputMode() const {
|
||||||
return _inputMode;
|
return _inputMode;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulsePropertyGroup WebEntityItem::getPulseProperties() const {
|
||||||
|
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||||
|
return _pulseProperties;
|
||||||
|
});
|
||||||
|
}
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
#include "PulsePropertyGroup.h"
|
||||||
|
|
||||||
class WebEntityItem : public EntityItem {
|
class WebEntityItem : public EntityItem {
|
||||||
public:
|
public:
|
||||||
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItemPointer factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
@ -30,7 +32,7 @@ public:
|
||||||
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
virtual EntityPropertyFlags getEntityProperties(EncodeBitstreamParams& params) const override;
|
||||||
|
|
||||||
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
virtual void appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params,
|
||||||
EntityTreeElementExtraEncodeDataPointer modelTreeElementExtraEncodeData,
|
EntityTreeElementExtraEncodeDataPointer entityTreeElementExtraEncodeData,
|
||||||
EntityPropertyFlags& requestedProperties,
|
EntityPropertyFlags& requestedProperties,
|
||||||
EntityPropertyFlags& propertyFlags,
|
EntityPropertyFlags& propertyFlags,
|
||||||
EntityPropertyFlags& propertiesDidntFit,
|
EntityPropertyFlags& propertiesDidntFit,
|
||||||
|
@ -75,9 +77,12 @@ public:
|
||||||
void setInputMode(const WebInputMode& value);
|
void setInputMode(const WebInputMode& value);
|
||||||
WebInputMode getInputMode() const;
|
WebInputMode getInputMode() const;
|
||||||
|
|
||||||
|
PulsePropertyGroup getPulseProperties() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
glm::u8vec3 _color;
|
glm::u8vec3 _color;
|
||||||
float _alpha { 1.0f };
|
float _alpha { 1.0f };
|
||||||
|
PulsePropertyGroup _pulseProperties;
|
||||||
|
|
||||||
QString _sourceUrl;
|
QString _sourceUrl;
|
||||||
uint16_t _dpi;
|
uint16_t _dpi;
|
||||||
|
|
|
@ -258,6 +258,7 @@ enum class EntityVersion : PacketVersion {
|
||||||
FixProtocolVersionBumpMismatch,
|
FixProtocolVersionBumpMismatch,
|
||||||
MigrateOverlayRenderProperties,
|
MigrateOverlayRenderProperties,
|
||||||
MissingWebEntityProperties,
|
MissingWebEntityProperties,
|
||||||
|
PulseProperties,
|
||||||
|
|
||||||
// Add new versions above here
|
// Add new versions above here
|
||||||
NUM_PACKET_TYPE,
|
NUM_PACKET_TYPE,
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "RenderLayer.h"
|
#include "RenderLayer.h"
|
||||||
#include "PrimitiveMode.h"
|
#include "PrimitiveMode.h"
|
||||||
#include "WebInputMode.h"
|
#include "WebInputMode.h"
|
||||||
|
#include "PulseMode.h"
|
||||||
|
|
||||||
#include "OctreeConstants.h"
|
#include "OctreeConstants.h"
|
||||||
#include "OctreeElement.h"
|
#include "OctreeElement.h"
|
||||||
|
@ -269,6 +270,7 @@ public:
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, RenderLayer& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
static int unpackDataFromBytes(const unsigned char* dataBytes, RenderLayer& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, PrimitiveMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
static int unpackDataFromBytes(const unsigned char* dataBytes, PrimitiveMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, WebInputMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
static int unpackDataFromBytes(const unsigned char* dataBytes, WebInputMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||||
|
static int unpackDataFromBytes(const unsigned char* dataBytes, PulseMode& result) { memcpy(&result, dataBytes, sizeof(result)); return sizeof(result); }
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, glm::vec2& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, glm::vec2& result);
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, glm::vec3& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, glm::vec3& result);
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, glm::u8vec3& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, glm::u8vec3& result);
|
||||||
|
|
25
libraries/shared/src/PulseMode.cpp
Normal file
25
libraries/shared/src/PulseMode.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 1/15/19
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "PulseMode.h"
|
||||||
|
|
||||||
|
const char* pulseModeNames[] = {
|
||||||
|
"none",
|
||||||
|
"in",
|
||||||
|
"out"
|
||||||
|
};
|
||||||
|
|
||||||
|
static const size_t PULSE_MODE_NAMES = (sizeof(pulseModeNames) / sizeof(pulseModeNames[0]));
|
||||||
|
|
||||||
|
QString PulseModeHelpers::getNameForPulseMode(PulseMode mode) {
|
||||||
|
if (((int)mode <= 0) || ((int)mode >= (int)PULSE_MODE_NAMES)) {
|
||||||
|
mode = (PulseMode)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pulseModeNames[(int)mode];
|
||||||
|
}
|
41
libraries/shared/src/PulseMode.h
Normal file
41
libraries/shared/src/PulseMode.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// Created by Sam Gondelman on 1/15/19.
|
||||||
|
// Copyright 2019 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_PulseMode_h
|
||||||
|
#define hifi_PulseMode_h
|
||||||
|
|
||||||
|
#include "QString"
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* <p>Pulse modes for color and alpha pulsing.</p>
|
||||||
|
* <table>
|
||||||
|
* <thead>
|
||||||
|
* <tr><th>Value</th><th>Description</th></tr>
|
||||||
|
* </thead>
|
||||||
|
* <tbody>
|
||||||
|
* <tr><td><code>none</code></td><td>No pulsing.</td></tr>
|
||||||
|
* <tr><td><code>in</code></td><td>Pulse in phase with the pulse period.</td></tr>
|
||||||
|
* <tr><td><code>out</code></td><td>Pulse out of phase with the pulse period.</td></tr>
|
||||||
|
* </tbody>
|
||||||
|
* </table>
|
||||||
|
* @typedef {string} PulseMode
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum class PulseMode {
|
||||||
|
NONE = 0,
|
||||||
|
IN_PHASE,
|
||||||
|
OUT_PHASE
|
||||||
|
};
|
||||||
|
|
||||||
|
class PulseModeHelpers {
|
||||||
|
public:
|
||||||
|
static QString getNameForPulseMode(PulseMode mode);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_PulseMode_h
|
||||||
|
|
Loading…
Reference in a new issue