mirror of
https://github.com/lubosz/overte.git
synced 2025-04-25 01:23:57 +02:00
some cleanup
This commit is contained in:
parent
afe7c386c3
commit
dce73ea428
10 changed files with 13 additions and 92 deletions
|
@ -71,9 +71,8 @@ namespace controller {
|
|||
}
|
||||
|
||||
Pose Pose::postTransform(const glm::mat4& mat) const {
|
||||
glm::mat4 original = getMat4();
|
||||
glm::mat4 original = ::createMatFromQuatAndPos(rotation, translation);
|
||||
glm::mat4 result = original * mat;
|
||||
|
||||
auto translationOut = ::extractTranslation(result);
|
||||
auto rotationOut = ::glmExtractRotation(result);
|
||||
auto velocityOut = velocity + glm::cross(angularVelocity, translation - translationOut); // warning: this may be completely wrong
|
||||
|
|
|
@ -43,8 +43,6 @@ namespace controller {
|
|||
Pose transform(const glm::mat4& mat) const;
|
||||
Pose postTransform(const glm::mat4& mat) const;
|
||||
|
||||
glm::mat4 getMat4() const { return ::createMatFromQuatAndPos(rotation, translation); }
|
||||
|
||||
static QScriptValue toScriptValue(QScriptEngine* engine, const Pose& event);
|
||||
static void fromScriptValue(const QScriptValue& object, Pose& event);
|
||||
};
|
||||
|
|
|
@ -93,8 +93,7 @@ bool Filter::parseSingleFloatParameter(const QJsonValue& parameters, const QStri
|
|||
return false;
|
||||
}
|
||||
|
||||
// FIXME - we're not really using the name
|
||||
bool Filter::parseVec3Parameter(const QJsonValue& parameters, const QString& name, glm::vec3& output) {
|
||||
bool Filter::parseVec3Parameter(const QJsonValue& parameters, glm::vec3& output) {
|
||||
if (parameters.isDouble()) {
|
||||
output = glm::vec3(parameters.toDouble());
|
||||
return true;
|
||||
|
@ -163,7 +162,7 @@ bool Filter::parseMat4Parameter(const QJsonValue& parameters, glm::mat4& output)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Filter::parseQuatParameter(const QJsonValue& parameters, const QString& name, glm::quat& output) {
|
||||
bool Filter::parseQuatParameter(const QJsonValue& parameters, glm::quat& output) {
|
||||
if (parameters.isObject()) {
|
||||
auto objectParameters = parameters.toObject();
|
||||
if (objectParameters.contains("w") &&
|
||||
|
|
|
@ -46,8 +46,8 @@ namespace controller {
|
|||
static Factory& getFactory() { return _factory; }
|
||||
|
||||
static bool parseSingleFloatParameter(const QJsonValue& parameters, const QString& name, float& output);
|
||||
static bool parseVec3Parameter(const QJsonValue& parameters, const QString& name, glm::vec3& output);
|
||||
static bool parseQuatParameter(const QJsonValue& parameters, const QString& name, glm::quat& output);
|
||||
static bool parseVec3Parameter(const QJsonValue& parameters, glm::vec3& output);
|
||||
static bool parseQuatParameter(const QJsonValue& parameters, glm::quat& output);
|
||||
static bool parseMat4Parameter(const QJsonValue& parameters, glm::mat4& output);
|
||||
protected:
|
||||
static Factory _factory;
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
//
|
||||
// Created by Brad Hefta-Gaub 2017/04/11
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "RotateFilter.h"
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
|
||||
#include <StreamUtils.h>
|
||||
|
||||
using namespace controller;
|
||||
|
||||
bool RotateFilter::parseParameters(const QJsonValue& parameters) {
|
||||
static const QString JSON_ROTATION = QStringLiteral("rotation");
|
||||
return parseQuatParameter(parameters, JSON_ROTATION, _rotation);
|
||||
}
|
|
@ -25,11 +25,10 @@ public:
|
|||
virtual float apply(float value) const override { return value; }
|
||||
|
||||
virtual Pose apply(Pose value) const override {
|
||||
glm::quat temp = _rotation;
|
||||
return value.transform(glm::mat4(temp));
|
||||
return value.transform(glm::mat4(glm::quat(_rotation)));
|
||||
}
|
||||
|
||||
virtual bool parseParameters(const QJsonValue& parameters) override;
|
||||
virtual bool parseParameters(const QJsonValue& parameters) override { return parseQuatParameter(parameters, _rotation); }
|
||||
|
||||
private:
|
||||
glm::quat _rotation;
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis 2015/10/25
|
||||
// Copyright 2015 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 "TransformFilter.h"
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
|
||||
#include <StreamUtils.h>
|
||||
|
||||
using namespace controller;
|
||||
|
||||
bool TransformFilter::parseParameters(const QJsonValue& parameters) {
|
||||
return parseMat4Parameter(parameters, _transform);
|
||||
}
|
|
@ -22,15 +22,9 @@ public:
|
|||
TransformFilter() { }
|
||||
TransformFilter(glm::mat4 transform) : _transform(transform) {}
|
||||
|
||||
virtual float apply(float value) const override {
|
||||
return value;
|
||||
}
|
||||
|
||||
virtual Pose apply(Pose value) const override {
|
||||
return value.transform(_transform);
|
||||
}
|
||||
|
||||
virtual bool parseParameters(const QJsonValue& parameters) override;
|
||||
virtual float apply(float value) const override { return value; }
|
||||
virtual Pose apply(Pose value) const override { return value.transform(_transform); }
|
||||
virtual bool parseParameters(const QJsonValue& parameters) override { return parseMat4Parameter(parameters, _transform); }
|
||||
|
||||
private:
|
||||
glm::mat4 _transform;
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis 2015/10/25
|
||||
// Copyright 2015 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 "TranslateFilter.h"
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QJsonArray>
|
||||
|
||||
#include <StreamUtils.h>
|
||||
|
||||
using namespace controller;
|
||||
|
||||
bool TranslateFilter::parseParameters(const QJsonValue& parameters) {
|
||||
static const QString JSON_TRANSLATE = QStringLiteral("translate");
|
||||
return parseVec3Parameter(parameters, JSON_TRANSLATE, _translate);
|
||||
}
|
|
@ -22,15 +22,9 @@ public:
|
|||
TranslateFilter() { }
|
||||
TranslateFilter(glm::vec3 translate) : _translate(translate) {}
|
||||
|
||||
virtual float apply(float value) const override {
|
||||
return value;
|
||||
}
|
||||
|
||||
virtual Pose apply(Pose value) const override {
|
||||
return value.transform(glm::translate(_translate));
|
||||
}
|
||||
|
||||
virtual bool parseParameters(const QJsonValue& parameters) override;
|
||||
virtual float apply(float value) const override { return value; }
|
||||
virtual Pose apply(Pose value) const override { return value.transform(glm::translate(_translate)); }
|
||||
virtual bool parseParameters(const QJsonValue& parameters) override { return parseVec3Parameter(parameters, _translate); }
|
||||
|
||||
private:
|
||||
glm::vec3 _translate { 0.0f };
|
||||
|
|
Loading…
Reference in a new issue