mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 20:24:13 +02:00
replace QVariantMap glm::vec3 setters with conversions for QScriptValue
This commit is contained in:
parent
a07b673f69
commit
e977d28fe3
4 changed files with 23 additions and 43 deletions
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
#include <RegisteredMetaTypes.h>
|
||||||
#include <UDPSocket.h>
|
#include <UDPSocket.h>
|
||||||
|
|
||||||
#include "AudioRingBuffer.h"
|
#include "AudioRingBuffer.h"
|
||||||
|
@ -24,8 +25,6 @@ const int MAX_INJECTOR_VOLUME = 0xFF;
|
||||||
|
|
||||||
const int INJECT_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SAMPLE_RATE) * 1000000);
|
const int INJECT_INTERVAL_USECS = floorf((BUFFER_LENGTH_SAMPLES_PER_CHANNEL / SAMPLE_RATE) * 1000000);
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(glm::vec3)
|
|
||||||
|
|
||||||
class AudioInjector : public QObject {
|
class AudioInjector : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -52,38 +52,6 @@ AvatarData::~AvatarData() {
|
||||||
delete _handData;
|
delete _handData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setPositionFromVariantMap(QVariantMap positionMap) {
|
|
||||||
_position = glm::vec3(positionMap.value("x").toFloat(),
|
|
||||||
positionMap.value("y").toFloat(),
|
|
||||||
positionMap.value("z").toFloat());
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap AvatarData::getPositionVariantMap() {
|
|
||||||
QVariantMap positionMap;
|
|
||||||
|
|
||||||
positionMap.insert("x", _position.x);
|
|
||||||
positionMap.insert("y", _position.y);
|
|
||||||
positionMap.insert("z", _position.z);
|
|
||||||
|
|
||||||
return positionMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AvatarData::setHandPositionFromVariantMap(QVariantMap handPositionMap) {
|
|
||||||
_handPosition = glm::vec3(handPositionMap.value("x").toFloat(),
|
|
||||||
handPositionMap.value("y").toFloat(),
|
|
||||||
handPositionMap.value("z").toFloat());
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap AvatarData::getHandPositionVariantMap() {
|
|
||||||
QVariantMap positionMap;
|
|
||||||
|
|
||||||
positionMap.insert("x", _handPosition.x);
|
|
||||||
positionMap.insert("y", _handPosition.y);
|
|
||||||
positionMap.insert("z", _handPosition.z);
|
|
||||||
|
|
||||||
return positionMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AvatarData::sendData() {
|
void AvatarData::sendData() {
|
||||||
|
|
||||||
// called from Agent visual loop to send data
|
// called from Agent visual loop to send data
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QVariantMap>
|
#include <QtCore/QVariantMap>
|
||||||
|
|
||||||
|
#include <RegisteredMetaTypes.h>
|
||||||
|
|
||||||
#include <NodeData.h>
|
#include <NodeData.h>
|
||||||
#include "HeadData.h"
|
#include "HeadData.h"
|
||||||
#include "HandData.h"
|
#include "HandData.h"
|
||||||
|
@ -48,8 +50,8 @@ class JointData;
|
||||||
class AvatarData : public NodeData {
|
class AvatarData : public NodeData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QVariantMap position READ getPositionVariantMap WRITE setPositionFromVariantMap)
|
Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition)
|
||||||
Q_PROPERTY(QVariantMap handPosition READ getHandPositionVariantMap WRITE setHandPositionFromVariantMap)
|
Q_PROPERTY(glm::vec3 handPosition READ getHandPosition WRITE setHandPosition)
|
||||||
Q_PROPERTY(float bodyYaw READ getBodyYaw WRITE setBodyYaw)
|
Q_PROPERTY(float bodyYaw READ getBodyYaw WRITE setBodyYaw)
|
||||||
Q_PROPERTY(float bodyPitch READ getBodyPitch WRITE setBodyPitch)
|
Q_PROPERTY(float bodyPitch READ getBodyPitch WRITE setBodyPitch)
|
||||||
Q_PROPERTY(float bodyRoll READ getBodyRoll WRITE setBodyRoll)
|
Q_PROPERTY(float bodyRoll READ getBodyRoll WRITE setBodyRoll)
|
||||||
|
@ -59,16 +61,11 @@ public:
|
||||||
~AvatarData();
|
~AvatarData();
|
||||||
|
|
||||||
const glm::vec3& getPosition() const { return _position; }
|
const glm::vec3& getPosition() const { return _position; }
|
||||||
|
|
||||||
void setPosition(const glm::vec3 position) { _position = position; }
|
void setPosition(const glm::vec3 position) { _position = position; }
|
||||||
|
|
||||||
|
const glm::vec3& getHandPosition() const { return _handPosition; }
|
||||||
void setHandPosition(const glm::vec3 handPosition) { _handPosition = handPosition; }
|
void setHandPosition(const glm::vec3 handPosition) { _handPosition = handPosition; }
|
||||||
|
|
||||||
void setPositionFromVariantMap(QVariantMap positionMap);
|
|
||||||
QVariantMap getPositionVariantMap();
|
|
||||||
|
|
||||||
void setHandPositionFromVariantMap(QVariantMap handPositionMap);
|
|
||||||
QVariantMap getHandPositionVariantMap();
|
|
||||||
|
|
||||||
int getBroadcastData(unsigned char* destinationBuffer);
|
int getBroadcastData(unsigned char* destinationBuffer);
|
||||||
int parseData(unsigned char* sourceBuffer, int numBytes);
|
int parseData(unsigned char* sourceBuffer, int numBytes);
|
||||||
|
|
||||||
|
|
16
libraries/shared/src/RegisteredMetaTypes.h
Normal file
16
libraries/shared/src/RegisteredMetaTypes.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
//
|
||||||
|
// RegisteredMetaTypes.h
|
||||||
|
// hifi
|
||||||
|
//
|
||||||
|
// Created by Stephen Birarda on 10/3/13.
|
||||||
|
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Used to register meta-types with Qt so that they can be used as properties for objects exposed to our
|
||||||
|
// Agent scripting.
|
||||||
|
|
||||||
|
#ifndef hifi_RegisteredMetaTypes_h
|
||||||
|
#define hifi_RegisteredMetaTypes_h
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(glm::vec3)
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue