mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into make-fixupMissingParents-more-thread-safe
This commit is contained in:
commit
1d63f6d354
24 changed files with 137 additions and 94 deletions
|
@ -467,37 +467,6 @@
|
|||
var elZTextureURL = document.getElementById("property-z-texture-url");
|
||||
|
||||
var elPreviewCameraButton = document.getElementById("preview-camera-button");
|
||||
|
||||
var urlUpdaters = document.getElementsByClassName("update-url-version");
|
||||
var PARAM_REGEXP = /(?:\?)(\S+)/; // Check if this has any parameters.
|
||||
var TIMESTAMP_REGEXP = /(&?HFTime=\d+)/;
|
||||
|
||||
var refreshEvent = function (event) {
|
||||
var urlElement = event.target.parentElement.getElementsByTagName("INPUT")[0];
|
||||
var content = urlElement.value;
|
||||
var date = new Date();
|
||||
var timeStamp = date.getTime();
|
||||
|
||||
if(content.length > 0){
|
||||
if(PARAM_REGEXP.test(content)){
|
||||
// Has params, so lets remove existing definition and append again.
|
||||
content = content.replace(TIMESTAMP_REGEXP,"") + "&";
|
||||
}else{
|
||||
content += "?";
|
||||
}
|
||||
content = content.replace("?&","?");
|
||||
urlElement.value = content + "HFTime=" + timeStamp;
|
||||
}
|
||||
|
||||
var evt = document.createEvent("HTMLEvents");
|
||||
evt.initEvent("change", true, true );
|
||||
urlElement.dispatchEvent(evt);
|
||||
};
|
||||
|
||||
for(var index = 0; index < urlUpdaters.length; index++){
|
||||
var urlUpdater = urlUpdaters[index];
|
||||
urlUpdater.addEventListener("click", refreshEvent, true);
|
||||
}
|
||||
|
||||
if (window.EventBridge !== undefined) {
|
||||
var properties;
|
||||
|
@ -1397,20 +1366,17 @@
|
|||
<option value="3">Edged marching cubes</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="spatial-group poly-vox-section property url refresh">
|
||||
<div class="spatial-group poly-vox-section property url ">
|
||||
<label for="property-x-texture-url">X-axis texture URL</label>
|
||||
<input type="text" id="property-x-texture-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
<div class="spatial-group poly-vox-section property url refresh">
|
||||
<div class="spatial-group poly-vox-section property url ">
|
||||
<label for="property-y-texture-url">Y-axis texture URL</label>
|
||||
<input type="text" id="property-y-texture-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
<div class="spatial-group poly-vox-section property url refresh">
|
||||
<div class="spatial-group poly-vox-section property url ">
|
||||
<label for="property-z-texture-url">Z-axis texture URL</label>
|
||||
<input type="text" id="property-z-texture-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
<div class="spatial-group property pyr">
|
||||
<label>Rotation</label>
|
||||
|
@ -1545,16 +1511,15 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="behavior-group property url refresh">
|
||||
<div class="behavior-group property url ">
|
||||
<label for="property-collision-sound-url">Collision sound URL</label>
|
||||
<input type="text" id="property-collision-sound-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
<div class="behavior-group property number">
|
||||
<label>Lifetime</label>
|
||||
<input type="number" id="property-lifetime">
|
||||
</div>
|
||||
<div class="behavior-group property url refresh">
|
||||
<div class="behavior-group property url ">
|
||||
<!--
|
||||
FIXME: If reload buttons at the end of each URL continue to work OK during beta, this reload button and associated
|
||||
code should be removed.
|
||||
|
@ -1563,17 +1528,15 @@
|
|||
-->
|
||||
<label for="property-script-url">Script URL</label>
|
||||
<input type="text" id="property-script-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
|
||||
|
||||
<div class="section-header model-group model-section zone-section">
|
||||
<label>Model</label><span>M</span>
|
||||
</div>
|
||||
<div class="model-group model-section property url refresh">
|
||||
<div class="model-group model-section property url ">
|
||||
<label for="property-model-url">Model URL</label>
|
||||
<input type="text" id="property-model-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
<div class="model-group model-section zone-section property dropdown">
|
||||
<label>Collision shape type</label>
|
||||
|
@ -1584,15 +1547,13 @@
|
|||
<option value="compound">Compound</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="model-group model-section zone-section property url refresh">
|
||||
<div class="model-group model-section zone-section property url ">
|
||||
<label for="property-compound-shape-url">Compound shape URL</label>
|
||||
<input type="text" id="property-compound-shape-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
<div class="model-group model-section property url refresh">
|
||||
<div class="model-group model-section property url ">
|
||||
<label for="property-model-animation-url">Animation URL</label>
|
||||
<input type="text" id="property-model-animation-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
<div class="model-group model-section property checkbox">
|
||||
<input type="checkbox" id="property-model-animation-playing">
|
||||
|
@ -1693,10 +1654,9 @@
|
|||
<label>Ambient intensity</label>
|
||||
<input type="number" id="property-zone-key-ambient-intensity" min="0" max="10" step="0.1">
|
||||
</div>
|
||||
<div class="zone-group zone-section keylight-section property url refresh">
|
||||
<div class="zone-group zone-section keylight-section property url ">
|
||||
<label for="property-zone-key-ambient-url">Ambient URL</label>
|
||||
<input type="text" id="property-zone-key-ambient-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
|
||||
<div class="sub-section-header zone-group zone-section stage-section">
|
||||
|
@ -1745,20 +1705,18 @@
|
|||
<div><input type="number" class="blue" id="property-zone-skybox-color-blue"><label for="property-zone-skybox-color-blue">Blue:</label></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="zone-group zone-section skybox-section property url refresh">
|
||||
<div class="zone-group zone-section skybox-section property url ">
|
||||
<label for="property-zone-skybox-url">Skybox URL</label>
|
||||
<input type="text" id="property-zone-skybox-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
|
||||
|
||||
<div class="section-header web-group web-section">
|
||||
<label>Web</label><span>M</span>
|
||||
</div>
|
||||
<div class="web-group web-section property url refresh">
|
||||
<div class="web-group web-section property url ">
|
||||
<label for="property-web-source-url">Source URL</label>
|
||||
<input type="text" id="property-web-source-url">
|
||||
<input type="button" class="update-url-version glyph" value="F" />
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Desktop {
|
|||
Component.onCompleted: {
|
||||
WebEngine.settings.javascriptCanOpenWindows = true;
|
||||
WebEngine.settings.javascriptCanAccessClipboard = false;
|
||||
WebEngine.settings.spatialNavigationEnabled = true;
|
||||
WebEngine.settings.spatialNavigationEnabled = false;
|
||||
WebEngine.settings.localContentCanAccessRemoteUrls = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -187,9 +187,10 @@ void Avatar::simulate(float deltaTime) {
|
|||
|
||||
// simple frustum check
|
||||
float boundingRadius = getBoundingRadius();
|
||||
bool inView = qApp->getDisplayViewFrustum()->sphereIntersectsFrustum(getPosition(), boundingRadius);
|
||||
bool avatarPositionInView = qApp->getDisplayViewFrustum()->sphereIntersectsFrustum(getPosition(), boundingRadius);
|
||||
bool avatarMeshInView = qApp->getDisplayViewFrustum()->boxIntersectsFrustum(_skeletonModel->getRenderableMeshBound());
|
||||
|
||||
if (_shouldAnimate && !_shouldSkipRender && inView) {
|
||||
if (_shouldAnimate && !_shouldSkipRender && (avatarPositionInView || avatarMeshInView)) {
|
||||
{
|
||||
PerformanceTimer perfTimer("skeleton");
|
||||
_skeletonModel->getRig()->copyJointsFromJointData(_jointData);
|
||||
|
|
|
@ -92,7 +92,7 @@ private:
|
|||
public: \
|
||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override { return _renderHelper.addToScene(self, scene, pendingChanges); } \
|
||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges) override { _renderHelper.removeFromScene(self, scene, pendingChanges); } \
|
||||
virtual void locationChanged() override { EntityItem::locationChanged(); _renderHelper.notifyChanged(); } \
|
||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); _renderHelper.notifyChanged(); } \
|
||||
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); _renderHelper.notifyChanged(); } \
|
||||
private: \
|
||||
SimpleRenderableEntityItem _renderHelper;
|
||||
|
|
|
@ -271,10 +271,10 @@ bool RenderableModelEntityItem::getAnimationFrame() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!hasAnimation() || !_jointMappingCompleted) {
|
||||
if (!hasRenderAnimation() || !_jointMappingCompleted) {
|
||||
return false;
|
||||
}
|
||||
AnimationPointer myAnimation = getAnimation(_animationProperties.getURL()); // FIXME: this could be optimized
|
||||
AnimationPointer myAnimation = getAnimation(getRenderAnimationURL()); // FIXME: this could be optimized
|
||||
if (myAnimation && myAnimation->isLoaded()) {
|
||||
|
||||
const QVector<FBXAnimationFrame>& frames = myAnimation->getFramesReference(); // NOTE: getFrames() is too heavy
|
||||
|
@ -384,7 +384,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
}
|
||||
|
||||
if (_model) {
|
||||
if (hasAnimation()) {
|
||||
if (hasRenderAnimation()) {
|
||||
if (!jointsMapped()) {
|
||||
QStringList modelJointNames = _model->getJointNames();
|
||||
mapJoints(modelJointNames);
|
||||
|
@ -528,6 +528,9 @@ void RenderableModelEntityItem::update(const quint64& now) {
|
|||
}
|
||||
}
|
||||
|
||||
// make a copy of the animation properites
|
||||
_renderAnimationProperties = _animationProperties;
|
||||
|
||||
ModelEntityItem::update(now);
|
||||
}
|
||||
|
||||
|
@ -795,8 +798,8 @@ void RenderableModelEntityItem::setJointTranslationsSet(const QVector<bool>& tra
|
|||
}
|
||||
|
||||
|
||||
void RenderableModelEntityItem::locationChanged() {
|
||||
EntityItem::locationChanged();
|
||||
void RenderableModelEntityItem::locationChanged(bool tellPhysics) {
|
||||
EntityItem::locationChanged(tellPhysics);
|
||||
if (_model && _model->isActive()) {
|
||||
_model->setRotation(getRotation());
|
||||
_model->setTranslation(getPosition());
|
||||
|
|
|
@ -75,13 +75,18 @@ public:
|
|||
virtual void setJointTranslationsSet(const QVector<bool>& translationsSet) override;
|
||||
|
||||
virtual void loader() override;
|
||||
virtual void locationChanged() override;
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
|
||||
virtual void resizeJointArrays(int newSize = -1) override;
|
||||
|
||||
virtual int getJointIndex(const QString& name) const override;
|
||||
virtual QStringList getJointNames() const override;
|
||||
|
||||
// These operate on a copy of the renderAnimationProperties, so they can be accessed
|
||||
// without having the entityTree lock.
|
||||
bool hasRenderAnimation() const { return !_renderAnimationProperties.getURL().isEmpty(); }
|
||||
const QString& getRenderAnimationURL() const { return _renderAnimationProperties.getURL(); }
|
||||
|
||||
private:
|
||||
QVariantMap parseTexturesToMap(QString textures);
|
||||
void remapTextures();
|
||||
|
@ -97,6 +102,8 @@ private:
|
|||
QVector<QVector<glm::vec3>> _points;
|
||||
bool _dimensionsInitialized = true;
|
||||
|
||||
AnimationPropertyGroup _renderAnimationProperties;
|
||||
|
||||
render::ItemID _myMetaItem{ render::Item::INVALID_ITEM_ID };
|
||||
|
||||
bool _showCollisionHull = false;
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
InterpolationData<float> radius;
|
||||
InterpolationData<glm::vec4> color; // rgba
|
||||
float lifespan;
|
||||
glm::vec3 spare;
|
||||
};
|
||||
|
||||
struct ParticlePrimitive {
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
virtual void removeFromScene(EntityItemPointer self, render::ScenePointer scene, render::PendingChanges& pendingChanges) override;
|
||||
|
||||
protected:
|
||||
virtual void locationChanged() override { EntityItem::locationChanged(); notifyBoundChanged(); }
|
||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); }
|
||||
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); notifyBoundChanged(); }
|
||||
|
||||
void notifyBoundChanged();
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::PendingChanges& pendingChanges);
|
||||
|
||||
private:
|
||||
virtual void locationChanged() override { EntityItem::locationChanged(); notifyBoundChanged(); }
|
||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); }
|
||||
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); notifyBoundChanged(); }
|
||||
void notifyBoundChanged();
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ struct Colors {
|
|||
struct ParticleUniforms {
|
||||
Radii radius;
|
||||
Colors color;
|
||||
float lifespan;
|
||||
vec4 lifespan; // x is lifespan, 3 spare floats
|
||||
};
|
||||
|
||||
uniform particleBuffer {
|
||||
layout(std140) uniform particleBuffer {
|
||||
ParticleUniforms particle;
|
||||
};
|
||||
|
||||
|
@ -112,7 +112,7 @@ void main(void) {
|
|||
int twoTriID = gl_VertexID - particleID * NUM_VERTICES_PER_PARTICLE;
|
||||
|
||||
// Particle properties
|
||||
float age = inColor.x / particle.lifespan;
|
||||
float age = inColor.x / particle.lifespan.x;
|
||||
float seed = inColor.y;
|
||||
|
||||
// Pass the texcoord and the z texcoord is representing the texture icon
|
||||
|
|
|
@ -244,6 +244,10 @@ void AnimationPropertyGroup::markAllChanged() {
|
|||
_fpsChanged = true;
|
||||
_currentFrameChanged = true;
|
||||
_runningChanged = true;
|
||||
_loopChanged = true;
|
||||
_firstFrameChanged = true;
|
||||
_lastFrameChanged = true;
|
||||
_holdChanged = true;
|
||||
}
|
||||
|
||||
EntityPropertyFlags AnimationPropertyGroup::getChangedProperties() const {
|
||||
|
|
|
@ -888,9 +888,6 @@ void EntityItem::simulateKinematicMotion(float timeElapsed, bool setFlags) {
|
|||
if (hasActions()) {
|
||||
return;
|
||||
}
|
||||
if (!_parentID.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasLocalAngularVelocity()) {
|
||||
glm::vec3 localAngularVelocity = getLocalAngularVelocity();
|
||||
|
@ -1976,14 +1973,16 @@ QList<EntityActionPointer> EntityItem::getActionsOfType(EntityActionType typeToG
|
|||
return result;
|
||||
}
|
||||
|
||||
void EntityItem::locationChanged() {
|
||||
void EntityItem::locationChanged(bool tellPhysics) {
|
||||
requiresRecalcBoxes();
|
||||
_dirtyFlags |= Simulation::DIRTY_TRANSFORM;
|
||||
if (tellPhysics) {
|
||||
_dirtyFlags |= Simulation::DIRTY_TRANSFORM;
|
||||
}
|
||||
EntityTreePointer tree = getTree();
|
||||
if (tree) {
|
||||
tree->entityChanged(getThisPointer());
|
||||
}
|
||||
SpatiallyNestable::locationChanged(); // tell all the children, also
|
||||
SpatiallyNestable::locationChanged(tellPhysics); // tell all the children, also
|
||||
}
|
||||
|
||||
void EntityItem::dimensionsChanged() {
|
||||
|
|
|
@ -432,7 +432,7 @@ protected:
|
|||
const QByteArray getActionDataInternal() const;
|
||||
void setActionDataInternal(QByteArray actionData);
|
||||
|
||||
virtual void locationChanged() override;
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
virtual void dimensionsChanged() override;
|
||||
|
||||
EntityTypes::EntityType _type;
|
||||
|
|
|
@ -12,11 +12,12 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
|||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS);
|
||||
format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS);
|
||||
format.setVersion(4, 5);
|
||||
setGLFormatVersion(format);
|
||||
#ifdef DEBUG
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
#endif
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
});
|
||||
return format;
|
||||
}
|
||||
|
@ -27,11 +28,12 @@ const QGLFormat& getDefaultGLFormat() {
|
|||
static QGLFormat glFormat;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
glFormat.setVersion(4, 5);
|
||||
setGLFormatVersion(glFormat);
|
||||
glFormat.setProfile(QGLFormat::CoreProfile); // Requires >=Qt-4.8.0
|
||||
glFormat.setSampleBuffers(false);
|
||||
glFormat.setDepth(false);
|
||||
glFormat.setStencil(false);
|
||||
QGLFormat::setDefaultFormat(glFormat);
|
||||
});
|
||||
return glFormat;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
class QSurfaceFormat;
|
||||
class QGLFormat;
|
||||
|
||||
template<class F>
|
||||
void setGLFormatVersion(F& format, int major = 4, int minor = 5) { format.setVersion(major, minor); }
|
||||
|
||||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
|
||||
const QGLFormat& getDefaultGLFormat();
|
||||
#endif
|
||||
|
|
|
@ -569,7 +569,7 @@ QPointF OffscreenQmlSurface::mapToVirtualScreen(const QPointF& originalPoint, QO
|
|||
// Event handling customization
|
||||
//
|
||||
|
||||
bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* event) {
|
||||
bool OffscreenQmlSurface::filterEnabled(QObject* originalDestination, QEvent* event) const {
|
||||
if (_renderer->_quickWindow == originalDestination) {
|
||||
return false;
|
||||
}
|
||||
|
@ -577,7 +577,13 @@ bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* even
|
|||
if (_paused) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OffscreenQmlSurface::eventFilter(QObject* originalDestination, QEvent* event) {
|
||||
if (!filterEnabled(originalDestination, event)) {
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
// Don't intercept our own events, or we enter an infinite recursion
|
||||
QObject* recurseTest = originalDestination;
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
QQmlContext* getRootContext();
|
||||
|
||||
QPointF mapToVirtualScreen(const QPointF& originalPoint, QObject* originalWidget);
|
||||
virtual bool eventFilter(QObject* originalDestination, QEvent* event);
|
||||
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
||||
|
||||
signals:
|
||||
void textureUpdated(unsigned int texture);
|
||||
|
@ -76,6 +76,9 @@ public slots:
|
|||
void requestRender();
|
||||
void onAboutToQuit();
|
||||
|
||||
protected:
|
||||
bool filterEnabled(QObject* originalDestination, QEvent* event) const;
|
||||
|
||||
private:
|
||||
QObject* finishQmlLoad(std::function<void(QQmlContext*, QObject*)> f);
|
||||
QPointF mapWindowToUi(const QPointF& sourcePosition, QObject* sourceObject);
|
||||
|
|
|
@ -207,8 +207,16 @@ void EntityMotionState::setWorldTransform(const btTransform& worldTrans) {
|
|||
|
||||
assert(entityTreeIsLocked());
|
||||
measureBodyAcceleration();
|
||||
_entity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset());
|
||||
_entity->setRotation(bulletToGLM(worldTrans.getRotation()));
|
||||
bool positionSuccess;
|
||||
_entity->setPosition(bulletToGLM(worldTrans.getOrigin()) + ObjectMotionState::getWorldOffset(), positionSuccess, false);
|
||||
if (!positionSuccess) {
|
||||
qDebug() << "EntityMotionState::setWorldTransform setPosition failed" << _entity->getID();
|
||||
}
|
||||
bool orientationSuccess;
|
||||
_entity->setOrientation(bulletToGLM(worldTrans.getRotation()), orientationSuccess, false);
|
||||
if (!orientationSuccess) {
|
||||
qDebug() << "EntityMotionState::setWorldTransform setOrientation failed" << _entity->getID();
|
||||
}
|
||||
_entity->setVelocity(getBodyLinearVelocity());
|
||||
_entity->setAngularVelocity(getBodyAngularVelocity());
|
||||
_entity->setLastSimulated(usecTimestampNow());
|
||||
|
|
|
@ -314,7 +314,7 @@ glm::vec3 SpatiallyNestable::getPosition(int jointIndex, bool& success) const {
|
|||
return getTransform(jointIndex, success).getTranslation();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success) {
|
||||
void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success, bool tellPhysics) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(position)) {
|
||||
success = false;
|
||||
|
@ -328,7 +328,7 @@ void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success) {
|
|||
Transform::inverseMult(_transform, parentTransform, myWorldTransform);
|
||||
});
|
||||
if (success) {
|
||||
locationChanged();
|
||||
locationChanged(tellPhysics);
|
||||
} else {
|
||||
qDebug() << "setPosition failed for" << getID();
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ glm::quat SpatiallyNestable::getOrientation(int jointIndex, bool& success) const
|
|||
return getTransform(jointIndex, success).getRotation();
|
||||
}
|
||||
|
||||
void SpatiallyNestable::setOrientation(const glm::quat& orientation, bool& success) {
|
||||
void SpatiallyNestable::setOrientation(const glm::quat& orientation, bool& success, bool tellPhysics) {
|
||||
// guard against introducing NaN into the transform
|
||||
if (isNaN(orientation)) {
|
||||
success = false;
|
||||
|
@ -378,7 +378,7 @@ void SpatiallyNestable::setOrientation(const glm::quat& orientation, bool& succe
|
|||
Transform::inverseMult(_transform, parentTransform, myWorldTransform);
|
||||
});
|
||||
if (success) {
|
||||
locationChanged();
|
||||
locationChanged(tellPhysics);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,8 +422,18 @@ void SpatiallyNestable::setVelocity(const glm::vec3& velocity, bool& success) {
|
|||
glm::vec3 parentVelocity = getParentVelocity(success);
|
||||
Transform parentTransform = getParentTransform(success);
|
||||
_velocityLock.withWriteLock([&] {
|
||||
// TODO: take parent angularVelocity into account.
|
||||
_velocity = glm::inverse(parentTransform.getRotation()) * (velocity - parentVelocity);
|
||||
// HACK: until we are treating _velocity the same way we treat _position (meaning,
|
||||
// _velocity is a vs parent value and any request for a world-frame velocity must
|
||||
// be computed), do this to avoid equipped (parenting-grabbed) things from drifting.
|
||||
// turning a zero velocity into a non-zero _velocity (because the avatar is moving)
|
||||
// causes EntityItem::simulateKinematicMotion to have an effect on the equipped entity,
|
||||
// which causes it to drift from the hand.
|
||||
if (hasAncestorOfType(NestableType::Avatar)) {
|
||||
_velocity = velocity;
|
||||
} else {
|
||||
// TODO: take parent angularVelocity into account.
|
||||
_velocity = glm::inverse(parentTransform.getRotation()) * (velocity - parentVelocity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -751,9 +761,9 @@ void SpatiallyNestable::forEachDescendant(std::function<void(SpatiallyNestablePo
|
|||
}
|
||||
}
|
||||
|
||||
void SpatiallyNestable::locationChanged() {
|
||||
void SpatiallyNestable::locationChanged(bool tellPhysics) {
|
||||
forEachChild([&](SpatiallyNestablePointer object) {
|
||||
object->locationChanged();
|
||||
object->locationChanged(tellPhysics);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -59,13 +59,13 @@ public:
|
|||
|
||||
virtual glm::vec3 getPosition(bool& success) const;
|
||||
virtual glm::vec3 getPosition() const;
|
||||
virtual void setPosition(const glm::vec3& position, bool& success);
|
||||
virtual void setPosition(const glm::vec3& position, bool& success, bool tellPhysics = true);
|
||||
virtual void setPosition(const glm::vec3& position);
|
||||
|
||||
virtual glm::quat getOrientation(bool& success) const;
|
||||
virtual glm::quat getOrientation() const;
|
||||
virtual glm::quat getOrientation(int jointIndex, bool& success) const;
|
||||
virtual void setOrientation(const glm::quat& orientation, bool& success);
|
||||
virtual void setOrientation(const glm::quat& orientation, bool& success, bool tellPhysics = true);
|
||||
virtual void setOrientation(const glm::quat& orientation);
|
||||
|
||||
virtual glm::vec3 getVelocity(bool& success) const;
|
||||
|
@ -159,7 +159,7 @@ protected:
|
|||
mutable ReadWriteLockable _childrenLock;
|
||||
mutable QHash<QUuid, SpatiallyNestableWeakPointer> _children;
|
||||
|
||||
virtual void locationChanged(); // called when a this object's location has changed
|
||||
virtual void locationChanged(bool tellPhysics = true); // called when a this object's location has changed
|
||||
virtual void dimensionsChanged() { } // called when a this object's dimensions have changed
|
||||
|
||||
// _queryAACube is used to decide where something lives in the octree
|
||||
|
|
|
@ -563,5 +563,38 @@ QString OffscreenUi::getSaveFileName(void* ignored, const QString &caption, cons
|
|||
return DependencyManager::get<OffscreenUi>()->fileSaveDialog(caption, dir, filter, selectedFilter, options);
|
||||
}
|
||||
|
||||
bool OffscreenUi::eventFilter(QObject* originalDestination, QEvent* event) {
|
||||
if (!filterEnabled(originalDestination, event)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// let the parent class do it's work
|
||||
bool result = OffscreenQmlSurface::eventFilter(originalDestination, event);
|
||||
|
||||
// Check if this is a key press/release event that might need special attention
|
||||
auto type = event->type();
|
||||
if (type != QEvent::KeyPress && type != QEvent::KeyRelease) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QKeyEvent* keyEvent = dynamic_cast<QKeyEvent*>(event);
|
||||
bool& pressed = _pressedKeys[keyEvent->key()];
|
||||
|
||||
// Keep track of which key press events the QML has accepted
|
||||
if (result && QEvent::KeyPress == type) {
|
||||
pressed = true;
|
||||
}
|
||||
|
||||
// QML input elements absorb key press, but apparently not key release.
|
||||
// therefore we want to ensure that key release events for key presses that were
|
||||
// accepted by the QML layer are suppressed
|
||||
if (!result && type == QEvent::KeyRelease && pressed) {
|
||||
pressed = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#include "OffscreenUi.moc"
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#ifndef hifi_OffscreenUi_h
|
||||
#define hifi_OffscreenUi_h
|
||||
|
||||
#include <unordered_map>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtWidgets/QFileDialog>
|
||||
#include <QtWidgets/QMessageBox>
|
||||
|
@ -37,6 +38,7 @@ public:
|
|||
void setNavigationFocused(bool focused);
|
||||
void unfocusWindows();
|
||||
void toggleMenu(const QPoint& screenCoordinates);
|
||||
bool eventFilter(QObject* originalDestination, QEvent* event) override;
|
||||
|
||||
QQuickItem* getDesktop();
|
||||
QQuickItem* getToolWindow();
|
||||
|
@ -131,6 +133,7 @@ private:
|
|||
|
||||
QQuickItem* _desktop { nullptr };
|
||||
QQuickItem* _toolWindow { nullptr };
|
||||
std::unordered_map<int, bool> _pressedKeys;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <gl/QOpenGLContextWrapper.h>
|
||||
#include <gl/QOpenGLDebugLoggerWrapper.h>
|
||||
#include <gl/GLHelpers.h>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PathUtils.h>
|
||||
|
@ -141,7 +142,7 @@ public:
|
|||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(4, 3);
|
||||
setGLFormatVersion(format);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
format.setSwapInterval(0);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <gl/QOpenGLContextWrapper.h>
|
||||
#include <gl/QOpenGLDebugLoggerWrapper.h>
|
||||
#include <gl/GLHelpers.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QElapsedTimer>
|
||||
|
@ -98,7 +99,7 @@ public:
|
|||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(4, 1);
|
||||
setGLFormatVersion(format);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
|
||||
|
|
Loading…
Reference in a new issue