mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:40:11 +02:00
Scripting API cleanup and type conversion fixes
This commit is contained in:
parent
82e6cb9391
commit
a7229e9249
11 changed files with 21 additions and 48 deletions
|
@ -460,7 +460,8 @@ void MyAvatar::enableHandTouchForID(const QUuid& entityID) {
|
||||||
|
|
||||||
void MyAvatar::registerMetaTypes(ScriptEnginePointer engine) {
|
void MyAvatar::registerMetaTypes(ScriptEnginePointer engine) {
|
||||||
scriptRegisterMetaType<AudioListenerMode, audioListenModeToScriptValue, audioListenModeFromScriptValue>(engine.get());
|
scriptRegisterMetaType<AudioListenerMode, audioListenModeToScriptValue, audioListenModeFromScriptValue>(engine.get());
|
||||||
scriptRegisterMetaType<MyAvatar::DriveKeys, driveKeysToScriptValue, driveKeysFromScriptValue>(engine.get());
|
scriptRegisterMetaType<MyAvatar::DriveKeys, driveKeysToScriptValue, driveKeysFromScriptValue>(engine.get(), "DriveKeys");
|
||||||
|
qDebug() << "MyAvatar::registerMetaTypes";
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::registerProperties(ScriptEnginePointer engine) {
|
void MyAvatar::registerProperties(ScriptEnginePointer engine) {
|
||||||
|
|
|
@ -2291,13 +2291,6 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree = true) override;
|
void clearAvatarEntity(const QUuid& entityID, bool requiresRemovalFromTree = true) override;
|
||||||
|
|
||||||
/*@jsdoc
|
|
||||||
* @function MyAvatar.sanitizeAvatarEntityProperties
|
|
||||||
* @param {EntityItemProperties} properties - Properties.
|
|
||||||
* @deprecated This function is deprecated and will be removed.
|
|
||||||
*/
|
|
||||||
void sanitizeAvatarEntityProperties(EntityItemProperties& properties) const;
|
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* Sets whether your avatar mesh is visible to you.
|
* Sets whether your avatar mesh is visible to you.
|
||||||
* @function MyAvatar.setEnableMeshVisible
|
* @function MyAvatar.setEnableMeshVisible
|
||||||
|
@ -2689,6 +2682,7 @@ private:
|
||||||
virtual int parseDataFromBuffer(const QByteArray& buffer) override;
|
virtual int parseDataFromBuffer(const QByteArray& buffer) override;
|
||||||
virtual glm::vec3 getSkeletonPosition() const override;
|
virtual glm::vec3 getSkeletonPosition() const override;
|
||||||
int _skeletonModelChangeCount { 0 };
|
int _skeletonModelChangeCount { 0 };
|
||||||
|
void sanitizeAvatarEntityProperties(EntityItemProperties& properties) const;
|
||||||
|
|
||||||
void saveAvatarScale();
|
void saveAvatarScale();
|
||||||
|
|
||||||
|
@ -3119,6 +3113,8 @@ private:
|
||||||
QTimer _addAvatarEntitiesToTreeTimer;
|
QTimer _addAvatarEntitiesToTreeTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(MyAvatar::DriveKeys)
|
||||||
|
|
||||||
ScriptValue audioListenModeToScriptValue(ScriptEngine* engine, const AudioListenerMode& audioListenerMode);
|
ScriptValue audioListenModeToScriptValue(ScriptEngine* engine, const AudioListenerMode& audioListenerMode);
|
||||||
bool audioListenModeFromScriptValue(const ScriptValue& object, AudioListenerMode& audioListenerMode);
|
bool audioListenModeFromScriptValue(const ScriptValue& object, AudioListenerMode& audioListenerMode);
|
||||||
|
|
||||||
|
|
|
@ -508,9 +508,9 @@ void Audio::setReverb(bool enable) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::setReverbOptions(const AudioEffectOptions* options) {
|
void Audio::setReverbOptions(const AudioEffectOptions options) {
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
DependencyManager::get<AudioClient>()->setReverbOptions(options);
|
DependencyManager::get<AudioClient>()->setReverbOptions(&options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ public:
|
||||||
* @function Audio.setReverbOptions
|
* @function Audio.setReverbOptions
|
||||||
* @param {AudioEffectOptions} options - The reverberation options.
|
* @param {AudioEffectOptions} options - The reverberation options.
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void setReverbOptions(const AudioEffectOptions* options);
|
Q_INVOKABLE void setReverbOptions(const AudioEffectOptions options);
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* Sets the gain (relative volume) that avatars' voices are played at. This gain is used at the server.
|
* Sets the gain (relative volume) that avatars' voices are played at. This gain is used at the server.
|
||||||
|
|
|
@ -778,16 +778,6 @@ public:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE char getHandState() const { return _handState; }
|
Q_INVOKABLE char getHandState() const { return _handState; }
|
||||||
|
|
||||||
const QVector<JointData>& getRawJointData() const { return _jointData; }
|
|
||||||
|
|
||||||
/*@jsdoc
|
|
||||||
* Sets joint translations and rotations from raw joint data.
|
|
||||||
* @function Avatar.setRawJointData
|
|
||||||
* @param {JointData[]} data - The raw joint data.
|
|
||||||
* @deprecated This function is deprecated and will be removed.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void setRawJointData(QVector<JointData> data);
|
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* Sets a specific joint's rotation and position relative to its parent, in model coordinates.
|
* Sets a specific joint's rotation and position relative to its parent, in model coordinates.
|
||||||
* <p><strong>Warning:</strong> These coordinates are not necessarily in meters.</p>
|
* <p><strong>Warning:</strong> These coordinates are not necessarily in meters.</p>
|
||||||
|
@ -1706,6 +1696,9 @@ protected:
|
||||||
QByteArray packAvatarEntityTraitInstance(AvatarTraits::TraitInstanceID traitInstanceID);
|
QByteArray packAvatarEntityTraitInstance(AvatarTraits::TraitInstanceID traitInstanceID);
|
||||||
QByteArray packGrabTraitInstance(AvatarTraits::TraitInstanceID traitInstanceID);
|
QByteArray packGrabTraitInstance(AvatarTraits::TraitInstanceID traitInstanceID);
|
||||||
|
|
||||||
|
const QVector<JointData>& getRawJointData() const { return _jointData; }
|
||||||
|
void setRawJointData(QVector<JointData> data);
|
||||||
|
|
||||||
void unpackSkeletonModelURL(const QByteArray& data);
|
void unpackSkeletonModelURL(const QByteArray& data);
|
||||||
void unpackSkeletonData(const QByteArray& data);
|
void unpackSkeletonData(const QByteArray& data);
|
||||||
|
|
||||||
|
@ -1894,6 +1887,9 @@ private:
|
||||||
Q_DISABLE_COPY(AvatarData)
|
Q_DISABLE_COPY(AvatarData)
|
||||||
|
|
||||||
friend void avatarStateFromFrame(const QByteArray& frameData, AvatarData* _avatar);
|
friend void avatarStateFromFrame(const QByteArray& frameData, AvatarData* _avatar);
|
||||||
|
// Required for setRawJointData. Making setRawJointData public would expose it to scripting interface.
|
||||||
|
friend class SkeletonModel;
|
||||||
|
friend class MyAvatar;
|
||||||
static QUrl _defaultFullAvatarModelUrl;
|
static QUrl _defaultFullAvatarModelUrl;
|
||||||
};
|
};
|
||||||
Q_DECLARE_METATYPE(AvatarData*)
|
Q_DECLARE_METATYPE(AvatarData*)
|
||||||
|
|
|
@ -123,18 +123,10 @@ namespace controller {
|
||||||
return userInputMapper->getPose(Input((uint32_t)source));
|
return userInputMapper->getPose(Input((uint32_t)source));
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Action> ScriptingInterface::getAllActions() {
|
|
||||||
return DependencyManager::get<UserInputMapper>()->getAllActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ScriptingInterface::getDeviceName(unsigned int device) {
|
QString ScriptingInterface::getDeviceName(unsigned int device) {
|
||||||
return DependencyManager::get<UserInputMapper>()->getDeviceName((unsigned short)device);
|
return DependencyManager::get<UserInputMapper>()->getDeviceName((unsigned short)device);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Input::NamedPair> ScriptingInterface::getAvailableInputs(unsigned int device) {
|
|
||||||
return DependencyManager::get<UserInputMapper>()->getAvailableInputs((unsigned short)device);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScriptingInterface::findDevice(QString name) {
|
int ScriptingInterface::findDevice(QString name) {
|
||||||
return DependencyManager::get<UserInputMapper>()->findDevice(name);
|
return DependencyManager::get<UserInputMapper>()->findDevice(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,25 +73,6 @@ namespace controller {
|
||||||
ScriptingInterface();
|
ScriptingInterface();
|
||||||
virtual ~ScriptingInterface() {};
|
virtual ~ScriptingInterface() {};
|
||||||
|
|
||||||
/*@jsdoc
|
|
||||||
* Gets a list of all available actions.
|
|
||||||
* @function Controller.getAllActions
|
|
||||||
* @returns {Action[]} All available actions.
|
|
||||||
* @deprecated This function is deprecated and will be removed. It no longer works.
|
|
||||||
*/
|
|
||||||
// FIXME: This function causes a JavaScript crash: https://highfidelity.manuscript.com/f/cases/edit/13921
|
|
||||||
Q_INVOKABLE QVector<Action> getAllActions();
|
|
||||||
|
|
||||||
/*@jsdoc
|
|
||||||
* Gets a list of all available inputs for a hardware device.
|
|
||||||
* @function Controller.getAvailableInputs
|
|
||||||
* @param {number} deviceID - Integer ID of the hardware device.
|
|
||||||
* @returns {NamedPair[]} All available inputs for the device.
|
|
||||||
* @deprecated This function is deprecated and will be removed. It no longer works.
|
|
||||||
*/
|
|
||||||
// FIXME: This function causes a JavaScript crash: https://highfidelity.manuscript.com/f/cases/edit/13922
|
|
||||||
Q_INVOKABLE QVector<Input::NamedPair> getAvailableInputs(unsigned int device);
|
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* Finds the name of a particular controller from its device ID.
|
* Finds the name of a particular controller from its device ID.
|
||||||
* @function Controller.getDeviceName
|
* @function Controller.getDeviceName
|
||||||
|
|
|
@ -549,4 +549,6 @@ private:
|
||||||
QUrl _previousAPILookup;
|
QUrl _previousAPILookup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(AddressManager::LookupTrigger)
|
||||||
|
|
||||||
#endif // hifi_AddressManager_h
|
#endif // hifi_AddressManager_h
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "ScriptValueIterator.h"
|
#include "ScriptValueIterator.h"
|
||||||
#include "ScriptEngineLogging.h"
|
#include "ScriptEngineLogging.h"
|
||||||
#include "v8/FastScriptValueUtils.h"
|
#include "v8/FastScriptValueUtils.h"
|
||||||
|
#include "AddressManager.h"
|
||||||
|
|
||||||
bool isListOfStrings(const ScriptValue& arg) {
|
bool isListOfStrings(const ScriptValue& arg) {
|
||||||
if (!arg.isArray()) {
|
if (!arg.isArray()) {
|
||||||
|
@ -98,6 +99,8 @@ void registerMetaTypes(ScriptEngine* engine) {
|
||||||
scriptRegisterSequenceMetaType<QVector<glm::vec2>>(engine);
|
scriptRegisterSequenceMetaType<QVector<glm::vec2>>(engine);
|
||||||
scriptRegisterSequenceMetaType<QVector<glm::quat>>(engine);
|
scriptRegisterSequenceMetaType<QVector<glm::quat>>(engine);
|
||||||
scriptRegisterSequenceMetaType<QVector<QString>>(engine);
|
scriptRegisterSequenceMetaType<QVector<QString>>(engine);
|
||||||
|
|
||||||
|
scriptRegisterMetaType<AddressManager::LookupTrigger, scriptValueFromEnumClass<AddressManager::LookupTrigger>, scriptValueToEnumClass<AddressManager::LookupTrigger>>(engine, "LookupTrigger");
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptValue qVector2DToScriptValue(ScriptEngine* engine, const QVector2D& qVector2D) {
|
ScriptValue qVector2DToScriptValue(ScriptEngine* engine, const QVector2D& qVector2D) {
|
||||||
|
|
|
@ -37,6 +37,7 @@ STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
|
||||||
|
|
||||||
scriptRegisterMetaType<TabletProxy*, wrapperToScriptValue<TabletProxy>, wrapperFromScriptValue<TabletProxy> >(scriptEngine);
|
scriptRegisterMetaType<TabletProxy*, wrapperToScriptValue<TabletProxy>, wrapperFromScriptValue<TabletProxy> >(scriptEngine);
|
||||||
scriptRegisterMetaType<TabletButtonProxy*, wrapperToScriptValue<TabletButtonProxy>, wrapperFromScriptValue<TabletButtonProxy> >(scriptEngine);
|
scriptRegisterMetaType<TabletButtonProxy*, wrapperToScriptValue<TabletButtonProxy>, wrapperFromScriptValue<TabletButtonProxy> >(scriptEngine);
|
||||||
|
scriptRegisterMetaType<TabletScriptingInterface::TabletAudioEvents, scriptValueFromEnumClass<TabletScriptingInterface::TabletAudioEvents>, scriptValueToEnumClass<TabletScriptingInterface::TabletAudioEvents>>(scriptEngine);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// FIXME move to global app properties
|
// FIXME move to global app properties
|
||||||
|
|
|
@ -687,5 +687,6 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(TabletButtonProxy*);
|
Q_DECLARE_METATYPE(TabletButtonProxy*);
|
||||||
|
Q_DECLARE_METATYPE(TabletScriptingInterface::TabletAudioEvents)
|
||||||
|
|
||||||
#endif // hifi_TabletScriptingInterface_h
|
#endif // hifi_TabletScriptingInterface_h
|
||||||
|
|
Loading…
Reference in a new issue