mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:58:59 +02:00
commit
eebeca515e
17 changed files with 274 additions and 0 deletions
|
@ -104,6 +104,7 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
|
||||||
requestedProperties += PROP_IGNORE_PICK_INTERSECTION;
|
requestedProperties += PROP_IGNORE_PICK_INTERSECTION;
|
||||||
requestedProperties += PROP_RENDER_WITH_ZONES;
|
requestedProperties += PROP_RENDER_WITH_ZONES;
|
||||||
requestedProperties += PROP_BILLBOARD_MODE;
|
requestedProperties += PROP_BILLBOARD_MODE;
|
||||||
|
requestedProperties += PROP_TAGS;
|
||||||
requestedProperties += _grabProperties.getEntityProperties(params);
|
requestedProperties += _grabProperties.getEntityProperties(params);
|
||||||
requestedProperties += PROP_MIRROR_MODE;
|
requestedProperties += PROP_MIRROR_MODE;
|
||||||
requestedProperties += PROP_PORTAL_EXIT_ID;
|
requestedProperties += PROP_PORTAL_EXIT_ID;
|
||||||
|
@ -303,6 +304,7 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
||||||
APPEND_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, getIgnorePickIntersection());
|
APPEND_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, getIgnorePickIntersection());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_RENDER_WITH_ZONES, getRenderWithZones());
|
APPEND_ENTITY_PROPERTY(PROP_RENDER_WITH_ZONES, getRenderWithZones());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_BILLBOARD_MODE, (uint32_t)getBillboardMode());
|
APPEND_ENTITY_PROPERTY(PROP_BILLBOARD_MODE, (uint32_t)getBillboardMode());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_TAGS, getTags());
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
_grabProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
_grabProperties.appendSubclassData(packetData, params, entityTreeElementExtraEncodeData, requestedProperties,
|
||||||
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
propertyFlags, propertiesDidntFit, propertyCount, appendState);
|
||||||
|
@ -878,6 +880,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
|
||||||
READ_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, bool, setIgnorePickIntersection);
|
READ_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, bool, setIgnorePickIntersection);
|
||||||
READ_ENTITY_PROPERTY(PROP_RENDER_WITH_ZONES, QVector<QUuid>, setRenderWithZones);
|
READ_ENTITY_PROPERTY(PROP_RENDER_WITH_ZONES, QVector<QUuid>, setRenderWithZones);
|
||||||
READ_ENTITY_PROPERTY(PROP_BILLBOARD_MODE, BillboardMode, setBillboardMode);
|
READ_ENTITY_PROPERTY(PROP_BILLBOARD_MODE, BillboardMode, setBillboardMode);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_TAGS, QSet<QString>, setTags);
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
int bytesFromGrab = _grabProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
int bytesFromGrab = _grabProperties.readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
|
||||||
propertyFlags, overwriteLocalData,
|
propertyFlags, overwriteLocalData,
|
||||||
|
@ -1364,6 +1367,7 @@ EntityItemProperties EntityItem::getProperties(const EntityPropertyFlags& desire
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(ignorePickIntersection, getIgnorePickIntersection);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(ignorePickIntersection, getIgnorePickIntersection);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(renderWithZones, getRenderWithZones);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(renderWithZones, getRenderWithZones);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(billboardMode, getBillboardMode);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(billboardMode, getBillboardMode);
|
||||||
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(tags, getTags);
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
_grabProperties.getProperties(properties);
|
_grabProperties.getProperties(properties);
|
||||||
});
|
});
|
||||||
|
@ -1503,6 +1507,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(ignorePickIntersection, setIgnorePickIntersection);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(ignorePickIntersection, setIgnorePickIntersection);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(renderWithZones, setRenderWithZones);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(renderWithZones, setRenderWithZones);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(billboardMode, setBillboardMode);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(billboardMode, setBillboardMode);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(tags, setTags);
|
||||||
withWriteLock([&] {
|
withWriteLock([&] {
|
||||||
bool grabPropertiesChanged = _grabProperties.setProperties(properties);
|
bool grabPropertiesChanged = _grabProperties.setProperties(properties);
|
||||||
somethingChanged |= grabPropertiesChanged;
|
somethingChanged |= grabPropertiesChanged;
|
||||||
|
@ -3589,3 +3594,15 @@ void EntityItem::setPortalExitID(const QUuid& value) {
|
||||||
_portalExitID = value;
|
_portalExitID = value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityItem::setTags(const QSet<QString>& tags) {
|
||||||
|
withWriteLock([&] {
|
||||||
|
_tags = tags;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<QString> EntityItem::getTags() const {
|
||||||
|
return resultWithReadLock<QSet<QString>>([&] {
|
||||||
|
return _tags;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -565,6 +565,9 @@ public:
|
||||||
QUuid getPortalExitID() const;
|
QUuid getPortalExitID() const;
|
||||||
void setPortalExitID(const QUuid& value);
|
void setPortalExitID(const QUuid& value);
|
||||||
|
|
||||||
|
void setTags(const QSet<QString>& tags);
|
||||||
|
QSet<QString> getTags() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void spaceUpdate(std::pair<int32_t, glm::vec4> data);
|
void spaceUpdate(std::pair<int32_t, glm::vec4> data);
|
||||||
|
|
||||||
|
@ -749,6 +752,8 @@ protected:
|
||||||
MirrorMode _mirrorMode { MirrorMode::NONE };
|
MirrorMode _mirrorMode { MirrorMode::NONE };
|
||||||
QUuid _portalExitID;
|
QUuid _portalExitID;
|
||||||
|
|
||||||
|
QSet<QString> _tags;
|
||||||
|
|
||||||
mutable bool _needsRenderUpdate { false };
|
mutable bool _needsRenderUpdate { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,21 @@ void EntityItemProperties::setMirrorModeFromString(const QString& mirrorMode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QString> EntityItemProperties::getTagsAsVector() const {
|
||||||
|
QVector<QString> tags;
|
||||||
|
for (const QString& tag : _tags) {
|
||||||
|
tags.push_back(tag);
|
||||||
|
}
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EntityItemProperties::setTagsFromVector(const QVector<QString>& tags) {
|
||||||
|
_tags.clear();
|
||||||
|
for (const QString& tag : tags) {
|
||||||
|
_tags.insert(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
EntityPropertyFlags changedProperties;
|
EntityPropertyFlags changedProperties;
|
||||||
|
|
||||||
|
@ -471,6 +486,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
CHECK_PROPERTY_CHANGE(PROP_IGNORE_PICK_INTERSECTION, ignorePickIntersection);
|
CHECK_PROPERTY_CHANGE(PROP_IGNORE_PICK_INTERSECTION, ignorePickIntersection);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_RENDER_WITH_ZONES, renderWithZones);
|
CHECK_PROPERTY_CHANGE(PROP_RENDER_WITH_ZONES, renderWithZones);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_BILLBOARD_MODE, billboardMode);
|
CHECK_PROPERTY_CHANGE(PROP_BILLBOARD_MODE, billboardMode);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_TAGS, tags);
|
||||||
changedProperties += _grab.getChangedProperties();
|
changedProperties += _grab.getChangedProperties();
|
||||||
CHECK_PROPERTY_CHANGE(PROP_MIRROR_MODE, mirrorMode);
|
CHECK_PROPERTY_CHANGE(PROP_MIRROR_MODE, mirrorMode);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_PORTAL_EXIT_ID, portalExitID);
|
CHECK_PROPERTY_CHANGE(PROP_PORTAL_EXIT_ID, portalExitID);
|
||||||
|
@ -841,6 +857,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* one of the zones in this list.
|
* one of the zones in this list.
|
||||||
* @property {BillboardMode} billboardMode="none" - Whether the entity is billboarded to face the camera. Use the rotation
|
* @property {BillboardMode} billboardMode="none" - Whether the entity is billboarded to face the camera. Use the rotation
|
||||||
* property to control which axis is facing you.
|
* property to control which axis is facing you.
|
||||||
|
* @property {string[]} tags=[] - A set of tags describing this entity.
|
||||||
*
|
*
|
||||||
* @property {Entities.Grab} grab - The entity's grab-related properties.
|
* @property {Entities.Grab} grab - The entity's grab-related properties.
|
||||||
*
|
*
|
||||||
|
@ -1639,6 +1656,7 @@ ScriptValue EntityItemProperties::copyToScriptValue(ScriptEngine* engine, bool s
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IGNORE_PICK_INTERSECTION, ignorePickIntersection);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_IGNORE_PICK_INTERSECTION, ignorePickIntersection);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_RENDER_WITH_ZONES, renderWithZones);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_RENDER_WITH_ZONES, renderWithZones);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BILLBOARD_MODE, billboardMode, getBillboardModeAsString());
|
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_BILLBOARD_MODE, billboardMode, getBillboardModeAsString());
|
||||||
|
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_TAGS, tags, getTagsAsVector());
|
||||||
_grab.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
_grab.copyToScriptValue(_desiredProperties, properties, engine, skipDefaults, defaultEntityProperties);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_MIRROR_MODE, mirrorMode, getMirrorModeAsString());
|
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_MIRROR_MODE, mirrorMode, getMirrorModeAsString());
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_PORTAL_EXIT_ID, portalExitID);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_PORTAL_EXIT_ID, portalExitID);
|
||||||
|
@ -2057,6 +2075,7 @@ void EntityItemProperties::copyFromScriptValue(const ScriptValue& object, bool h
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(ignorePickIntersection, bool, setIgnorePickIntersection);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(ignorePickIntersection, bool, setIgnorePickIntersection);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(renderWithZones, qVectorQUuid, setRenderWithZones);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(renderWithZones, qVectorQUuid, setRenderWithZones);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(billboardMode, BillboardMode);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(billboardMode, BillboardMode);
|
||||||
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_GETTER(tags, qVectorQString, setTagsFromVector, getTagsAsVector);
|
||||||
_grab.copyFromScriptValue(object, namesSet, _defaultSettings);
|
_grab.copyFromScriptValue(object, namesSet, _defaultSettings);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(mirrorMode, MirrorMode);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(mirrorMode, MirrorMode);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(portalExitID, QUuid, setPortalExitID);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(portalExitID, QUuid, setPortalExitID);
|
||||||
|
@ -2345,6 +2364,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
|
||||||
COPY_PROPERTY_IF_CHANGED(ignorePickIntersection);
|
COPY_PROPERTY_IF_CHANGED(ignorePickIntersection);
|
||||||
COPY_PROPERTY_IF_CHANGED(renderWithZones);
|
COPY_PROPERTY_IF_CHANGED(renderWithZones);
|
||||||
COPY_PROPERTY_IF_CHANGED(billboardMode);
|
COPY_PROPERTY_IF_CHANGED(billboardMode);
|
||||||
|
COPY_PROPERTY_IF_CHANGED(tags);
|
||||||
_grab.merge(other._grab);
|
_grab.merge(other._grab);
|
||||||
COPY_PROPERTY_IF_CHANGED(mirrorMode);
|
COPY_PROPERTY_IF_CHANGED(mirrorMode);
|
||||||
COPY_PROPERTY_IF_CHANGED(portalExitID);
|
COPY_PROPERTY_IF_CHANGED(portalExitID);
|
||||||
|
@ -2635,6 +2655,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr
|
||||||
ADD_PROPERTY_TO_MAP(PROP_IGNORE_PICK_INTERSECTION, IgnorePickIntersection, ignorePickIntersection, bool);
|
ADD_PROPERTY_TO_MAP(PROP_IGNORE_PICK_INTERSECTION, IgnorePickIntersection, ignorePickIntersection, bool);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_RENDER_WITH_ZONES, RenderWithZones, renderWithZones, QVector<QUuid>);
|
ADD_PROPERTY_TO_MAP(PROP_RENDER_WITH_ZONES, RenderWithZones, renderWithZones, QVector<QUuid>);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_BILLBOARD_MODE, BillboardMode, billboardMode, BillboardMode);
|
ADD_PROPERTY_TO_MAP(PROP_BILLBOARD_MODE, BillboardMode, billboardMode, BillboardMode);
|
||||||
|
ADD_PROPERTY_TO_MAP(PROP_TAGS, Tags, tags, QSet<QString>);
|
||||||
{ // Grab
|
{ // Grab
|
||||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_GRAB_GRABBABLE, Grab, grab, Grabbable, grabbable);
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_GRAB_GRABBABLE, Grab, grab, Grabbable, grabbable);
|
||||||
ADD_GROUP_PROPERTY_TO_MAP(PROP_GRAB_KINEMATIC, Grab, grab, GrabKinematic, grabKinematic);
|
ADD_GROUP_PROPERTY_TO_MAP(PROP_GRAB_KINEMATIC, Grab, grab, GrabKinematic, grabKinematic);
|
||||||
|
@ -3119,6 +3140,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
APPEND_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, properties.getIgnorePickIntersection());
|
APPEND_ENTITY_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, properties.getIgnorePickIntersection());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_RENDER_WITH_ZONES, properties.getRenderWithZones());
|
APPEND_ENTITY_PROPERTY(PROP_RENDER_WITH_ZONES, properties.getRenderWithZones());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_BILLBOARD_MODE, (uint32_t)properties.getBillboardMode());
|
APPEND_ENTITY_PROPERTY(PROP_BILLBOARD_MODE, (uint32_t)properties.getBillboardMode());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_TAGS, properties.getTags());
|
||||||
_staticGrab.setProperties(properties);
|
_staticGrab.setProperties(properties);
|
||||||
_staticGrab.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
_staticGrab.appendToEditPacket(packetData, requestedProperties, propertyFlags,
|
||||||
propertiesDidntFit, propertyCount, appendState);
|
propertiesDidntFit, propertyCount, appendState);
|
||||||
|
@ -3601,6 +3623,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IGNORE_PICK_INTERSECTION, bool, setIgnorePickIntersection);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_IGNORE_PICK_INTERSECTION, bool, setIgnorePickIntersection);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_RENDER_WITH_ZONES, QVector<QUuid>, setRenderWithZones);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_RENDER_WITH_ZONES, QVector<QUuid>, setRenderWithZones);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BILLBOARD_MODE, BillboardMode, setBillboardMode);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_BILLBOARD_MODE, BillboardMode, setBillboardMode);
|
||||||
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_TAGS, QSet<QString>, setTags);
|
||||||
properties.getGrab().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
properties.getGrab().decodeFromEditPacket(propertyFlags, dataAt, processedBytes);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MIRROR_MODE, MirrorMode, setMirrorMode);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MIRROR_MODE, MirrorMode, setMirrorMode);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_PORTAL_EXIT_ID, QUuid, setPortalExitID);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_PORTAL_EXIT_ID, QUuid, setPortalExitID);
|
||||||
|
@ -3995,6 +4018,7 @@ void EntityItemProperties::markAllChanged() {
|
||||||
_ignorePickIntersectionChanged = true;
|
_ignorePickIntersectionChanged = true;
|
||||||
_renderWithZonesChanged = true;
|
_renderWithZonesChanged = true;
|
||||||
_billboardModeChanged = true;
|
_billboardModeChanged = true;
|
||||||
|
_tagsChanged = true;
|
||||||
_grab.markAllChanged();
|
_grab.markAllChanged();
|
||||||
_mirrorModeChanged = true;
|
_mirrorModeChanged = true;
|
||||||
_portalExitIDChanged = true;
|
_portalExitIDChanged = true;
|
||||||
|
@ -4396,6 +4420,9 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
||||||
if (billboardModeChanged()) {
|
if (billboardModeChanged()) {
|
||||||
out += "billboardMode";
|
out += "billboardMode";
|
||||||
}
|
}
|
||||||
|
if (tagsChanged()) {
|
||||||
|
out += "tags";
|
||||||
|
}
|
||||||
getGrab().listChangedProperties(out);
|
getGrab().listChangedProperties(out);
|
||||||
if (mirrorModeChanged()) {
|
if (mirrorModeChanged()) {
|
||||||
out += "mirrorMode";
|
out += "mirrorMode";
|
||||||
|
|
|
@ -204,6 +204,7 @@ public:
|
||||||
DEFINE_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, IgnorePickIntersection, ignorePickIntersection, bool, false);
|
DEFINE_PROPERTY(PROP_IGNORE_PICK_INTERSECTION, IgnorePickIntersection, ignorePickIntersection, bool, false);
|
||||||
DEFINE_PROPERTY_REF(PROP_RENDER_WITH_ZONES, RenderWithZones, renderWithZones, QVector<QUuid>, QVector<QUuid>());
|
DEFINE_PROPERTY_REF(PROP_RENDER_WITH_ZONES, RenderWithZones, renderWithZones, QVector<QUuid>, QVector<QUuid>());
|
||||||
DEFINE_PROPERTY_REF_ENUM(PROP_BILLBOARD_MODE, BillboardMode, billboardMode, BillboardMode, BillboardMode::NONE);
|
DEFINE_PROPERTY_REF_ENUM(PROP_BILLBOARD_MODE, BillboardMode, billboardMode, BillboardMode, BillboardMode::NONE);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_TAGS, Tags, tags, QSet<QString>, QSet<QString>());
|
||||||
DEFINE_PROPERTY_GROUP(Grab, grab, GrabPropertyGroup);
|
DEFINE_PROPERTY_GROUP(Grab, grab, GrabPropertyGroup);
|
||||||
DEFINE_PROPERTY_REF_ENUM(PROP_MIRROR_MODE, MirrorMode, mirrorMode, MirrorMode, MirrorMode::NONE);
|
DEFINE_PROPERTY_REF_ENUM(PROP_MIRROR_MODE, MirrorMode, mirrorMode, MirrorMode, MirrorMode::NONE);
|
||||||
DEFINE_PROPERTY_REF(PROP_PORTAL_EXIT_ID, PortalExitID, portalExitID, QUuid, UNKNOWN_ENTITY_ID);
|
DEFINE_PROPERTY_REF(PROP_PORTAL_EXIT_ID, PortalExitID, portalExitID, QUuid, UNKNOWN_ENTITY_ID);
|
||||||
|
@ -501,6 +502,9 @@ protected:
|
||||||
QString getCollisionMaskAsString() const;
|
QString getCollisionMaskAsString() const;
|
||||||
void setCollisionMaskFromString(const QString& maskString);
|
void setCollisionMaskFromString(const QString& maskString);
|
||||||
|
|
||||||
|
QVector<QString> getTagsAsVector() const;
|
||||||
|
void setTagsFromVector(const QVector<QString>& tags);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUuid _id;
|
QUuid _id;
|
||||||
bool _idSet;
|
bool _idSet;
|
||||||
|
|
|
@ -125,6 +125,7 @@ inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<glm::quat>&
|
||||||
inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<bool>& v) {return qVectorBoolToScriptValue(e, v); }
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<bool>& v) {return qVectorBoolToScriptValue(e, v); }
|
||||||
inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<float>& v) { return qVectorFloatToScriptValue(e, v); }
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<float>& v) { return qVectorFloatToScriptValue(e, v); }
|
||||||
inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<QUuid>& v) { return qVectorQUuidToScriptValue(e, v); }
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<QUuid>& v) { return qVectorQUuidToScriptValue(e, v); }
|
||||||
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const QVector<QString>& v) { return qVectorQStringToScriptValue(e, v); }
|
||||||
|
|
||||||
inline ScriptValue convertScriptValue(ScriptEngine* e, const QRect& v) { return qRectToScriptValue(e, v); }
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const QRect& v) { return qRectToScriptValue(e, v); }
|
||||||
|
|
||||||
|
@ -223,6 +224,7 @@ typedef QVector<glm::quat> qVectorQuat;
|
||||||
typedef QVector<bool> qVectorBool;
|
typedef QVector<bool> qVectorBool;
|
||||||
typedef QVector<float> qVectorFloat;
|
typedef QVector<float> qVectorFloat;
|
||||||
typedef QVector<QUuid> qVectorQUuid;
|
typedef QVector<QUuid> qVectorQUuid;
|
||||||
|
typedef QVector<QString> qVectorQString;
|
||||||
inline float float_convertFromScriptValue(const ScriptValue& v, bool& isValid) { return v.toVariant().toFloat(&isValid); }
|
inline float float_convertFromScriptValue(const ScriptValue& v, bool& isValid) { return v.toVariant().toFloat(&isValid); }
|
||||||
inline quint64 quint64_convertFromScriptValue(const ScriptValue& v, bool& isValid) { return v.toVariant().toULongLong(&isValid); }
|
inline quint64 quint64_convertFromScriptValue(const ScriptValue& v, bool& isValid) { return v.toVariant().toULongLong(&isValid); }
|
||||||
inline quint32 quint32_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
inline quint32 quint32_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
||||||
|
@ -305,6 +307,11 @@ inline qVectorQUuid qVectorQUuid_convertFromScriptValue(const ScriptValue& v, bo
|
||||||
return qVectorQUuidFromScriptValue(v);
|
return qVectorQUuidFromScriptValue(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline qVectorQString qVectorQString_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
||||||
|
isValid = true;
|
||||||
|
return qVectorQStringFromScriptValue(v);
|
||||||
|
}
|
||||||
|
|
||||||
inline glm::quat quat_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
inline glm::quat quat_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
||||||
isValid = false; /// assume it can't be converted
|
isValid = false; /// assume it can't be converted
|
||||||
ScriptValue x = v.property("x");
|
ScriptValue x = v.property("x");
|
||||||
|
|
|
@ -46,6 +46,7 @@ enum EntityPropertyList {
|
||||||
PROP_IGNORE_PICK_INTERSECTION,
|
PROP_IGNORE_PICK_INTERSECTION,
|
||||||
PROP_RENDER_WITH_ZONES,
|
PROP_RENDER_WITH_ZONES,
|
||||||
PROP_BILLBOARD_MODE,
|
PROP_BILLBOARD_MODE,
|
||||||
|
PROP_TAGS,
|
||||||
// Grab
|
// Grab
|
||||||
PROP_GRAB_GRABBABLE,
|
PROP_GRAB_GRABBABLE,
|
||||||
PROP_GRAB_KINEMATIC,
|
PROP_GRAB_KINEMATIC,
|
||||||
|
|
|
@ -1457,6 +1457,17 @@ QVector<QUuid> EntityScriptingInterface::findEntitiesByName(const QString entity
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QUuid> EntityScriptingInterface::findEntitiesByTags(const QVector<QString> entityTags, const glm::vec3& center, float radius, bool caseSensitiveSearch) const {
|
||||||
|
QVector<QUuid> result;
|
||||||
|
if (_entityTree) {
|
||||||
|
_entityTree->withReadLock([&] {
|
||||||
|
unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES);
|
||||||
|
_entityTree->evalEntitiesInSphereWithTags(center, radius, entityTags, caseSensitiveSearch, PickFilter(searchFilter), result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking,
|
RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersection(const PickRay& ray, bool precisionPicking,
|
||||||
const ScriptValue& entityIdsToInclude, const ScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) const {
|
const ScriptValue& entityIdsToInclude, const ScriptValue& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) const {
|
||||||
PROFILE_RANGE(script_entities, __FUNCTION__);
|
PROFILE_RANGE(script_entities, __FUNCTION__);
|
||||||
|
|
|
@ -789,6 +789,25 @@ public slots:
|
||||||
Q_INVOKABLE QVector<QUuid> findEntitiesByName(const QString entityName, const glm::vec3& center, float radius,
|
Q_INVOKABLE QVector<QUuid> findEntitiesByName(const QString entityName, const glm::vec3& center, float radius,
|
||||||
bool caseSensitiveSearch = false) const;
|
bool caseSensitiveSearch = false) const;
|
||||||
|
|
||||||
|
/*@jsdoc
|
||||||
|
* Finds all domain and avatar entities with particular tags that intersect a sphere.
|
||||||
|
* <p><strong>Note:</strong> Server entity scripts only find entities that have a server entity script
|
||||||
|
* running in them or a parent entity. You can apply a dummy script to entities that you want found in a search.</p>
|
||||||
|
* @function Entities.findEntitiesByTags
|
||||||
|
* @param {string[]} entityTags - The tags of the entity to search for.
|
||||||
|
* @param {Vec3} center - The point about which to search.
|
||||||
|
* @param {number} radius - The radius within which to search.
|
||||||
|
* @param {boolean} [caseSensitive=false] - <code>true</code> if the search is case-sensitive, <code>false</code> if it is
|
||||||
|
* case-insensitive.
|
||||||
|
* @returns {Uuid[]} An array of entity IDs that have the specified name and intersect the search sphere. The array is
|
||||||
|
* empty if no entities could be found.
|
||||||
|
* @example <caption>Report the number of entities with the tag, "Light-Target".</caption>
|
||||||
|
* var entityIDs = Entities.findEntitiesByTags(["Light-Target"], MyAvatar.position, 10, false);
|
||||||
|
* print("Number of entities with the tag Light-Target: " + entityIDs.length);
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE QVector<QUuid> findEntitiesByTags(const QVector<QString> entityTags, const glm::vec3& center, float radius,
|
||||||
|
bool caseSensitiveSearch = false) const;
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* Finds the first avatar or domain entity intersected by a {@link PickRay}. <code>Light</code> and <code>Zone</code>
|
* Finds the first avatar or domain entity intersected by a {@link PickRay}. <code>Light</code> and <code>Zone</code>
|
||||||
* entities are not intersected unless they've been configured as pickable using
|
* entities are not intersected unless they've been configured as pickable using
|
||||||
|
|
|
@ -1110,6 +1110,42 @@ void EntityTree::evalEntitiesInSphereWithName(const glm::vec3& center, float rad
|
||||||
foundEntities.swap(args.entities);
|
foundEntities.swap(args.entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FindEntitiesInSphereWithTagsArgs {
|
||||||
|
public:
|
||||||
|
// Inputs
|
||||||
|
glm::vec3 position;
|
||||||
|
float targetRadius;
|
||||||
|
QVector<QString> tags;
|
||||||
|
bool caseSensitive;
|
||||||
|
PickFilter searchFilter;
|
||||||
|
|
||||||
|
// Outputs
|
||||||
|
QVector<QUuid> entities;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool evalInSphereWithTagsOperation(const OctreeElementPointer& element, void* extraData) {
|
||||||
|
FindEntitiesInSphereWithTagsArgs* args = static_cast<FindEntitiesInSphereWithTagsArgs*>(extraData);
|
||||||
|
glm::vec3 penetration;
|
||||||
|
bool sphereIntersection = element->getAACube().findSpherePenetration(args->position, args->targetRadius, penetration);
|
||||||
|
|
||||||
|
// If this element contains the point, then search it...
|
||||||
|
if (sphereIntersection) {
|
||||||
|
EntityTreeElementPointer entityTreeElement = std::static_pointer_cast<EntityTreeElement>(element);
|
||||||
|
entityTreeElement->evalEntitiesInSphereWithTags(args->position, args->targetRadius, args->tags, args->caseSensitive, args->searchFilter, args->entities);
|
||||||
|
return true; // keep searching in case children have closer entities
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this element doesn't contain the point, then none of it's children can contain the point, so stop searching
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: assumes caller has handled locking
|
||||||
|
void EntityTree::evalEntitiesInSphereWithTags(const glm::vec3& center, float radius, const QVector<QString>& tags, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities) {
|
||||||
|
FindEntitiesInSphereWithTagsArgs args = { center, radius, tags, caseSensitive, searchFilter, QVector<QUuid>() };
|
||||||
|
recurseTreeWithOperation(evalInSphereWithTagsOperation, &args);
|
||||||
|
foundEntities.swap(args.entities);
|
||||||
|
}
|
||||||
|
|
||||||
class FindEntitiesInCubeArgs {
|
class FindEntitiesInCubeArgs {
|
||||||
public:
|
public:
|
||||||
// Inputs
|
// Inputs
|
||||||
|
|
|
@ -138,6 +138,7 @@ public:
|
||||||
void evalEntitiesInSphere(const glm::vec3& center, float radius, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
void evalEntitiesInSphere(const glm::vec3& center, float radius, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
||||||
void evalEntitiesInSphereWithType(const glm::vec3& center, float radius, EntityTypes::EntityType type, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
void evalEntitiesInSphereWithType(const glm::vec3& center, float radius, EntityTypes::EntityType type, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
||||||
void evalEntitiesInSphereWithName(const glm::vec3& center, float radius, const QString& name, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
void evalEntitiesInSphereWithName(const glm::vec3& center, float radius, const QString& name, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
||||||
|
void evalEntitiesInSphereWithTags(const glm::vec3& center, float radius, const QVector<QString>& tags, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
||||||
void evalEntitiesInCube(const AACube& cube, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
void evalEntitiesInCube(const AACube& cube, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
||||||
void evalEntitiesInBox(const AABox& box, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
void evalEntitiesInBox(const AABox& box, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
||||||
void evalEntitiesInFrustum(const ViewFrustum& frustum, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
void evalEntitiesInFrustum(const ViewFrustum& frustum, PickFilter searchFilter, QVector<QUuid>& foundEntities);
|
||||||
|
|
|
@ -602,6 +602,78 @@ void EntityTreeElement::evalEntitiesInSphereWithName(const glm::vec3& position,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityTreeElement::evalEntitiesInSphereWithTags(const glm::vec3& position, float radius, const QVector<QString>& tags, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities) const {
|
||||||
|
forEachEntity([&](EntityItemPointer entity) {
|
||||||
|
if (!checkFilterSettings(entity, searchFilter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSet<QString> entityTags = entity->getTags();
|
||||||
|
for (const QString& tag : tags) {
|
||||||
|
if (caseSensitive && !entityTags.contains(tag)) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
const QString lowerTag = tag.toLower();
|
||||||
|
bool found = false;
|
||||||
|
for (const QString& entityTag : entityTags) {
|
||||||
|
if (lowerTag == entityTag.toLower()) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool success;
|
||||||
|
AABox entityBox = entity->getAABox(success);
|
||||||
|
|
||||||
|
// if the sphere doesn't intersect with our world frame AABox, we don't need to consider the more complex case
|
||||||
|
glm::vec3 penetration;
|
||||||
|
if (success && entityBox.findSpherePenetration(position, radius, penetration)) {
|
||||||
|
|
||||||
|
glm::vec3 dimensions = entity->getScaledDimensions();
|
||||||
|
|
||||||
|
// FIXME - consider allowing the entity to determine penetration so that
|
||||||
|
// entities could presumably do actual hull testing if they wanted to
|
||||||
|
// FIXME - handle entity->getShapeType() == SHAPE_TYPE_SPHERE case better in particular
|
||||||
|
// can we handle the ellipsoid case better? We only currently handle perfect spheres
|
||||||
|
// with centered registration points
|
||||||
|
if (entity->getShapeType() == SHAPE_TYPE_SPHERE && (dimensions.x == dimensions.y && dimensions.y == dimensions.z)) {
|
||||||
|
|
||||||
|
// NOTE: entity->getRadius() doesn't return the true radius, it returns the radius of the
|
||||||
|
// maximum bounding sphere, which is actually larger than our actual radius
|
||||||
|
float entityTrueRadius = dimensions.x / 2.0f;
|
||||||
|
bool success;
|
||||||
|
glm::vec3 center = entity->getCenterPosition(success);
|
||||||
|
|
||||||
|
if (success && findSphereSpherePenetration(position, radius, center, entityTrueRadius, penetration)) {
|
||||||
|
foundEntities.push_back(entity->getID());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// determine the worldToEntityMatrix that doesn't include scale because
|
||||||
|
// we're going to use the registration aware aa box in the entity frame
|
||||||
|
glm::mat4 translation = glm::translate(entity->getWorldPosition());
|
||||||
|
glm::mat4 rotation = glm::mat4_cast(entity->getWorldOrientation());
|
||||||
|
glm::mat4 entityToWorldMatrix = translation * rotation;
|
||||||
|
glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix);
|
||||||
|
|
||||||
|
glm::vec3 registrationPoint = entity->getRegistrationPoint();
|
||||||
|
glm::vec3 corner = -(dimensions * registrationPoint) + entity->getPivot();
|
||||||
|
|
||||||
|
AABox entityFrameBox(corner, dimensions);
|
||||||
|
|
||||||
|
glm::vec3 entityFrameSearchPosition = glm::vec3(worldToEntityMatrix * glm::vec4(position, 1.0f));
|
||||||
|
if (entityFrameBox.findSpherePenetration(entityFrameSearchPosition, radius, penetration)) {
|
||||||
|
foundEntities.push_back(entity->getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void EntityTreeElement::evalEntitiesInCube(const AACube& cube, PickFilter searchFilter, QVector<QUuid>& foundEntities) const {
|
void EntityTreeElement::evalEntitiesInCube(const AACube& cube, PickFilter searchFilter, QVector<QUuid>& foundEntities) const {
|
||||||
forEachEntity([&](EntityItemPointer entity) {
|
forEachEntity([&](EntityItemPointer entity) {
|
||||||
if (!checkFilterSettings(entity, searchFilter)) {
|
if (!checkFilterSettings(entity, searchFilter)) {
|
||||||
|
|
|
@ -177,6 +177,7 @@ public:
|
||||||
void evalEntitiesInSphere(const glm::vec3& position, float radius, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
void evalEntitiesInSphere(const glm::vec3& position, float radius, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
||||||
void evalEntitiesInSphereWithType(const glm::vec3& position, float radius, EntityTypes::EntityType type, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
void evalEntitiesInSphereWithType(const glm::vec3& position, float radius, EntityTypes::EntityType type, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
||||||
void evalEntitiesInSphereWithName(const glm::vec3& position, float radius, const QString& name, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
void evalEntitiesInSphereWithName(const glm::vec3& position, float radius, const QString& name, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
||||||
|
void evalEntitiesInSphereWithTags(const glm::vec3& position, float radius, const QVector<QString>& tags, bool caseSensitive, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
||||||
void evalEntitiesInCube(const AACube& cube, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
void evalEntitiesInCube(const AACube& cube, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
||||||
void evalEntitiesInBox(const AABox& box, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
void evalEntitiesInBox(const AABox& box, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
||||||
void evalEntitiesInFrustum(const ViewFrustum& frustum, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
void evalEntitiesInFrustum(const ViewFrustum& frustum, PickFilter searchFilter, QVector<QUuid>& foundEntities) const;
|
||||||
|
|
|
@ -291,6 +291,7 @@ enum class EntityVersion : PacketVersion {
|
||||||
AllBillboardMode,
|
AllBillboardMode,
|
||||||
TextAlignment,
|
TextAlignment,
|
||||||
Mirror,
|
Mirror,
|
||||||
|
EntityTags,
|
||||||
|
|
||||||
// Add new versions above here
|
// Add new versions above here
|
||||||
NUM_PACKET_TYPE,
|
NUM_PACKET_TYPE,
|
||||||
|
|
|
@ -496,6 +496,24 @@ bool OctreePacketData::appendValue(const QVector<QUuid>& value) {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OctreePacketData::appendValue(const QSet<QString>& value) {
|
||||||
|
QVector<QString> valueVector;
|
||||||
|
for (const QString& valueString : value) {
|
||||||
|
valueVector.push_back(valueString);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t qVecSize = value.size();
|
||||||
|
bool success = appendValue(qVecSize);
|
||||||
|
if (success) {
|
||||||
|
success = append((const unsigned char*)valueVector.constData(), qVecSize * sizeof(QString));
|
||||||
|
if (success) {
|
||||||
|
_bytesOfValues += qVecSize * sizeof(QString);
|
||||||
|
_totalBytesOfValues += qVecSize * sizeof(QString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
bool OctreePacketData::appendValue(const glm::quat& value) {
|
bool OctreePacketData::appendValue(const glm::quat& value) {
|
||||||
const size_t VALUES_PER_QUAT = 4;
|
const size_t VALUES_PER_QUAT = 4;
|
||||||
const size_t PACKED_QUAT_SIZE = sizeof(uint16_t) * VALUES_PER_QUAT;
|
const size_t PACKED_QUAT_SIZE = sizeof(uint16_t) * VALUES_PER_QUAT;
|
||||||
|
@ -802,6 +820,23 @@ int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QVecto
|
||||||
return sizeof(uint16_t) + length * sizeof(QUuid);
|
return sizeof(uint16_t) + length * sizeof(QUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QSet<QString>& result) {
|
||||||
|
QVector<QString> resultVector;
|
||||||
|
|
||||||
|
uint16_t length;
|
||||||
|
memcpy(&length, dataBytes, sizeof(uint16_t));
|
||||||
|
dataBytes += sizeof(length);
|
||||||
|
resultVector.resize(length);
|
||||||
|
memcpy(resultVector.data(), dataBytes, length * sizeof(QString));
|
||||||
|
|
||||||
|
result.clear();
|
||||||
|
for (const QString& resultString : resultVector) {
|
||||||
|
result.insert(resultString);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sizeof(uint16_t) + length * sizeof(QString);
|
||||||
|
}
|
||||||
|
|
||||||
int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QByteArray& result) {
|
int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QByteArray& result) {
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
memcpy(&length, dataBytes, sizeof(length));
|
memcpy(&length, dataBytes, sizeof(length));
|
||||||
|
|
|
@ -191,6 +191,9 @@ public:
|
||||||
/// appends a QVector of QUuids to the end of the stream, may fail if new data stream is too long to fit in packet
|
/// appends a QVector of QUuids to the end of the stream, may fail if new data stream is too long to fit in packet
|
||||||
bool appendValue(const QVector<QUuid>& value);
|
bool appendValue(const QVector<QUuid>& value);
|
||||||
|
|
||||||
|
/// appends a QSet of QStrings to the end of the stream, may fail if new data stream is too long to fit in packet
|
||||||
|
bool appendValue(const QSet<QString>& value);
|
||||||
|
|
||||||
/// appends a packed quat to the end of the stream, may fail if new data stream is too long to fit in packet
|
/// appends a packed quat to the end of the stream, may fail if new data stream is too long to fit in packet
|
||||||
bool appendValue(const glm::quat& value);
|
bool appendValue(const glm::quat& value);
|
||||||
|
|
||||||
|
@ -292,6 +295,7 @@ public:
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, QVector<float>& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, QVector<float>& result);
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, QVector<bool>& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, QVector<bool>& result);
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, QVector<QUuid>& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, QVector<QUuid>& result);
|
||||||
|
static int unpackDataFromBytes(const unsigned char* dataBytes, QSet<QString>& result);
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, QByteArray& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, QByteArray& result);
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, AACube& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, AACube& result);
|
||||||
static int unpackDataFromBytes(const unsigned char* dataBytes, QRect& result);
|
static int unpackDataFromBytes(const unsigned char* dataBytes, QRect& result);
|
||||||
|
|
|
@ -862,6 +862,14 @@ bool quuidFromScriptValue(const ScriptValue& object, QUuid& uuid) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptValue qStringToScriptValue(ScriptEngine* engine, const QString& string) {
|
||||||
|
if (string.isNull()) {
|
||||||
|
return engine->nullValue();
|
||||||
|
}
|
||||||
|
ScriptValue obj(engine->newValue(string));
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
* A 2D size value.
|
* A 2D size value.
|
||||||
* @typedef {object} Size
|
* @typedef {object} Size
|
||||||
|
@ -1029,3 +1037,25 @@ QVector<EntityItemID> qVectorEntityItemIDFromScriptValue(const ScriptValue& arra
|
||||||
}
|
}
|
||||||
return newVector;
|
return newVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScriptValue qVectorQStringToScriptValue(ScriptEngine* engine, const QVector<QString>& vector) {
|
||||||
|
ScriptValue array = engine->newArray();
|
||||||
|
for (int i = 0; i < vector.size(); i++) {
|
||||||
|
array.setProperty(i, qStringToScriptValue(engine, vector.at(i)));
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QString> qVectorQStringFromScriptValue(const ScriptValue& array) {
|
||||||
|
if (!array.isArray()) {
|
||||||
|
return QVector<QString>();
|
||||||
|
}
|
||||||
|
QVector<QString> newVector;
|
||||||
|
int length = array.property("length").toInteger();
|
||||||
|
newVector.reserve(length);
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
QString string = array.property(i).toString();
|
||||||
|
newVector << string;
|
||||||
|
}
|
||||||
|
return newVector;
|
||||||
|
}
|
|
@ -224,6 +224,9 @@ ScriptValue qVectorQUuidToScriptValue(ScriptEngine* engine, const QVector<QUuid>
|
||||||
bool qVectorQUuidFromScriptValue(const ScriptValue& array, QVector<QUuid>& vector);
|
bool qVectorQUuidFromScriptValue(const ScriptValue& array, QVector<QUuid>& vector);
|
||||||
QVector<QUuid> qVectorQUuidFromScriptValue(const ScriptValue& array);
|
QVector<QUuid> qVectorQUuidFromScriptValue(const ScriptValue& array);
|
||||||
|
|
||||||
|
ScriptValue qVectorQStringToScriptValue(ScriptEngine* engine, const QVector<QString>& vector);
|
||||||
|
QVector<QString> qVectorQStringFromScriptValue(const ScriptValue& array);
|
||||||
|
|
||||||
class AACube;
|
class AACube;
|
||||||
ScriptValue aaCubeToScriptValue(ScriptEngine* engine, const AACube& aaCube);
|
ScriptValue aaCubeToScriptValue(ScriptEngine* engine, const AACube& aaCube);
|
||||||
bool aaCubeFromScriptValue(const ScriptValue& object, AACube& aaCube);
|
bool aaCubeFromScriptValue(const ScriptValue& object, AACube& aaCube);
|
||||||
|
|
Loading…
Reference in a new issue