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

This commit is contained in:
Daniela 2017-10-24 14:44:06 +01:00
commit 30a5b00b6e
16 changed files with 58 additions and 104 deletions

View file

@ -12,6 +12,7 @@
import QtQuick 2.5
import "../styles-uit"
import "../controls-uit" as HifiControls
import QtQuick.Controls 2.2
Item {
id: root;
@ -20,7 +21,7 @@ Item {
property var defaultThumbnails: [];
property var defaultFulls: [];
SkyboxSelectionModel {
ListModel {
id: skyboxModel;
}
@ -38,47 +39,22 @@ Item {
function sortSkyboxes(response) {
var arr = JSON.parse(response);
for (var i = 0; i < arr.length; i++) {
var arrLength = arr.length;
for (var i = 0; i < arrLength; i++) {
defaultThumbnails.push(arr[i].thumb);
defaultFulls.push(arr[i].full);
skyboxModel.append({});
}
setDefaultSkyboxes();
setSkyboxes();
}
function setDefaultSkyboxes() {
function setSkyboxes() {
for (var i = 0; i < skyboxModel.count; i++) {
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[i]);
skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[i]);
}
}
function shuffle(array) {
var tmp, current, top = array.length;
if (top) {
while (--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
}
return array;
}
function chooseRandom() {
for (var a = [], i=0; i < defaultFulls.length; ++i) {
a[i] = i;
}
a = shuffle(a);
for (var i = 0; i < skyboxModel.count; i++) {
skyboxModel.setProperty(i, "thumbnailPath", defaultThumbnails[a[i]]);
skyboxModel.setProperty(i, "fullSkyboxPath", defaultFulls[a[i]]);
}
}
Component.onCompleted: {
getSkyboxes();
}
@ -116,33 +92,18 @@ Item {
horizontalAlignment: Text.AlignHCenter;
verticalAlignment: Text.AlignVCenter;
}
HifiControls.Button {
id: randomButton
text: "Randomize"
color: hifi.buttons.blue
colorScheme: root.colorScheme
width: 100
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 5
anchors.rightMargin: 40
onClicked: {
chooseRandom()
}
}
}
GridView {
id: gridView
interactive: false
interactive: true
clip: true
anchors.top: titleBarContainer.bottom
anchors.topMargin: 20
anchors.horizontalCenter: parent.horizontalCenter
width: 400
height: parent.height
anchors.bottom: parent.bottom
currentIndex: -1
cellWidth: 200
cellHeight: 200
model: skyboxModel
@ -168,6 +129,14 @@ Item {
}
}
}
ScrollBar.vertical: ScrollBar {
parent: gridView.parent
anchors.top: gridView.top
anchors.left: gridView.right
anchors.bottom: gridView.bottom
anchors.leftMargin: 10
width: 19
}
}
signal sendToScript(var message);

View file

@ -1,40 +0,0 @@
//
// SkyboxSelectionModel.qml
// qml/hifi
//
// Created by Cain Kilgore on 21st October 2017
// Copyright 2017 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
//
import QtQuick 2.5
ListModel {
id: root;
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
ListElement{
thumbnailPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/thumbnails/thumb_1.jpg"
fullSkyboxPath: "http://mpassets.highfidelity.com/05904016-8f7d-4dfc-88e1-2bf9ba3fac20-v1/skyboxes/1.jpg"
}
}

View file

@ -5090,6 +5090,7 @@ void Application::update(float deltaTime) {
}
this->updateCamera(appRenderArgs._renderArgs);
appRenderArgs._eyeToWorld = _myCamera.getTransform();
appRenderArgs._isStereo = false;
{

View file

@ -96,6 +96,7 @@ void Line3DOverlay::setEnd(const glm::vec3& end) {
} else {
_direction = glm::vec3(0.0f);
}
notifyRenderTransformChange();
}
void Line3DOverlay::setLocalEnd(const glm::vec3& localEnd) {

View file

@ -50,7 +50,9 @@ void EntityRenderer::initEntityRenderers() {
REGISTER_ENTITY_TYPE_WITH_FACTORY(PolyVox, RenderablePolyVoxEntityItem::factory)
}
const Transform& EntityRenderer::getModelTransform() const {
return _modelTransform;
}
void EntityRenderer::makeStatusGetters(const EntityItemPointer& entity, Item::Status::Getters& statusGetters) {
auto nodeList = DependencyManager::get<NodeList>();

View file

@ -105,8 +105,10 @@ protected:
template<typename T>
std::shared_ptr<T> asTypedEntity() { return std::static_pointer_cast<T>(_entity); }
static void makeStatusGetters(const EntityItemPointer& entity, Item::Status::Getters& statusGetters);
static std::function<bool()> _entitiesShouldFadeFunction;
const Transform& getModelTransform() const;
SharedSoundPointer _collisionSound;
QUuid _changeHandlerId;
@ -114,7 +116,6 @@ protected:
quint64 _fadeStartTime{ usecTimestampNow() };
bool _isFading{ _entitiesShouldFadeFunction() };
bool _prevIsTransparent { false };
Transform _modelTransform;
Item::Bound _bound;
bool _visible { false };
bool _moving { false };
@ -123,6 +124,10 @@ protected:
private:
// 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
// transform
Transform _modelTransform;
// The rendering code only gets access to the entity in very specific circumstances
// i.e. to see if the rendering code needs to update because of a change in state of the
// entity. This forces all the rendering code itself to be independent of the entity

View file

@ -49,9 +49,10 @@ void LineEntityRenderer::doRender(RenderArgs* args) {
PerformanceTimer perfTimer("RenderableLineEntityItem::render");
Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch;
const auto& modelTransform = getModelTransform();
Transform transform = Transform();
transform.setTranslation(_modelTransform.getTranslation());
transform.setRotation(_modelTransform.getRotation());
transform.setTranslation(modelTransform.getTranslation());
transform.setRotation(modelTransform.getRotation());
batch.setModelTransform(transform);
if (_linePoints.size() > 1) {
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch);

View file

@ -1311,7 +1311,7 @@ void ModelEntityRenderer::doRender(RenderArgs* args) {
if (!model || (model && model->didVisualGeometryRequestFail())) {
static glm::vec4 greenColor(0.0f, 1.0f, 0.0f, 1.0f);
gpu::Batch& batch = *args->_batch;
batch.setModelTransform(_modelTransform); // we want to include the scale as well
batch.setModelTransform(getModelTransform()); // we want to include the scale as well
DependencyManager::get<GeometryCache>()->renderWireCubeInstance(args, batch, greenColor);
return;
}

View file

@ -251,12 +251,13 @@ void ParticleEffectEntityRenderer::stepSimulation() {
});
if (_emitting && particleProperties.emitting()) {
const auto& modelTransform = getModelTransform();
uint64_t emitInterval = particleProperties.emitIntervalUsecs();
if (emitInterval > 0 && interval >= _timeUntilNextEmit) {
auto timeRemaining = interval;
while (timeRemaining > _timeUntilNextEmit) {
// emit particle
_cpuParticles.push_back(createParticle(now, _modelTransform, particleProperties));
_cpuParticles.push_back(createParticle(now, modelTransform, particleProperties));
_timeUntilNextEmit = emitInterval;
if (emitInterval < timeRemaining) {
timeRemaining -= emitInterval;
@ -315,7 +316,7 @@ void ParticleEffectEntityRenderer::doRender(RenderArgs* args) {
// In trail mode, the particles are created in world space.
// so we only set a transform if they're not in trail mode
if (!_particleProperties.emission.shouldTrail) {
transform = _modelTransform;
transform = getModelTransform();
transform.setScale(vec3(1));
}
batch.setModelTransform(transform);

View file

@ -76,6 +76,14 @@ bool ShapeEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoin
return true;
}
if (_shape != entity->getShape()) {
return true;
}
if (_dimensions != entity->getDimensions()) {
return true;
}
return false;
}
@ -93,12 +101,13 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
_position = entity->getPosition();
_dimensions = entity->getDimensions();
_orientation = entity->getOrientation();
_renderTransform = getModelTransform();
if (_shape == entity::Sphere) {
_modelTransform.postScale(SPHERE_ENTITY_SCALE);
_renderTransform.postScale(SPHERE_ENTITY_SCALE);
}
_modelTransform.postScale(_dimensions);
_renderTransform.postScale(_dimensions);
});
}
@ -133,7 +142,7 @@ void ShapeEntityRenderer::doRender(RenderArgs* args) {
glm::vec4 outColor;
withReadLock([&] {
geometryShape = MAPPING[_shape];
batch.setModelTransform(_modelTransform); // use a transform with scale, rotation, registration point and translation
batch.setModelTransform(_renderTransform); // use a transform with scale, rotation, registration point and translation
outColor = _color;
if (_procedural.isReady()) {
_procedural.prepare(batch, _position, _dimensions, _orientation);

View file

@ -32,6 +32,7 @@ private:
Procedural _procedural;
QString _lastUserData;
Transform _renderTransform;
entity::Shape _shape { entity::Sphere };
glm::vec4 _color;
glm::vec3 _position;

View file

@ -93,10 +93,11 @@ void TextEntityRenderer::doRender(RenderArgs* args) {
Q_ASSERT(args->_batch);
gpu::Batch& batch = *args->_batch;
auto transformToTopLeft = _modelTransform;
const auto& modelTransform = getModelTransform();
auto transformToTopLeft = modelTransform;
if (_faceCamera) {
//rotate about vertical to face the camera
glm::vec3 dPosition = args->getViewFrustum().getPosition() - _modelTransform.getTranslation();
glm::vec3 dPosition = args->getViewFrustum().getPosition() - modelTransform.getTranslation();
// If x and z are 0, atan(x, z) is undefined, so default to 0 degrees
float yawRotation = dPosition.x == 0.0f && dPosition.z == 0.0f ? 0.0f : glm::atan(dPosition.x, dPosition.z);
glm::quat orientation = glm::quat(glm::vec3(0.0f, yawRotation, 0.0f));

View file

@ -139,8 +139,8 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
glm::vec2 windowSize = getWindowSize(entity);
_webSurface->resize(QSize(windowSize.x, windowSize.y));
_modelTransform.postScale(entity->getDimensions());
_renderTransform = getModelTransform();
_renderTransform.postScale(entity->getDimensions());
});
}
@ -180,7 +180,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
gpu::Batch& batch = *args->_batch;
withReadLock([&] {
batch.setModelTransform(_modelTransform);
batch.setModelTransform(_renderTransform);
});
batch.setResourceTexture(0, _texture);
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;

View file

@ -62,6 +62,7 @@ private:
uint16_t _lastDPI;
QTimer _timer;
uint64_t _lastRenderTime { 0 };
Transform _renderTransform;
};
} } // namespace

View file

@ -248,7 +248,8 @@ void ZoneEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) {
if (entity->getShapeType() == SHAPE_TYPE_SPHERE) {
_modelTransform.postScale(SPHERE_ENTITY_SCALE);
_renderTransform = getModelTransform();
_renderTransform.postScale(SPHERE_ENTITY_SCALE);
}
}

View file

@ -119,6 +119,7 @@ private:
bool _validSkyboxTexture{ false };
QString _proceduralUserData;
Transform _renderTransform;
};
} } // namespace