Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 10 files). Show all
Unified · Split
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include <VariantMapToScriptValue.h> |
| 22 | 22 | #include <SharedUtil.h> |
| 23 | 23 | #include <SpatialParentFinder.h> |
| 24 | +#include <model/MeshProxy.h> | |
| 24 | 25 | |
| 25 | 26 | #include "EntitiesLogging.h" |
| 26 | 27 | #include "EntityActionFactoryInterface.h" |
| @@ -1040,21 +1041,6 @@ bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3 · 1013 unmodified lines | ||
| 1040 | 1041 | }); |
| 1041 | 1042 | } |
| 1042 | 1043 | |
| 1043 | −void EntityScriptingInterface::voxelsToMesh(QUuid entityID, QScriptValue callback) { | |
| 1044 | − PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 1045 | − | |
| 1046 | − bool success { false }; | |
| 1047 | − QScriptValue mesh { false }; | |
| 1048 | − | |
| 1049 | − polyVoxWorker(entityID, [&](PolyVoxEntityItem& polyVoxEntity) mutable { | |
| 1050 | − success = polyVoxEntity.getMeshAsScriptValue(callback.engine(), mesh); | |
| 1051 | − return true; | |
| 1052 | − }); | |
| 1053 | − | |
| 1054 | − QScriptValueList args { mesh, success }; | |
| 1055 | − callback.call(QScriptValue(), args); | |
| 1056 | −} | |
| 1057 | − | |
| 1058 | 1044 | bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) { |
| 1059 | 1045 | PROFILE_RANGE(script_entities, __FUNCTION__); |
| 1060 | 1046 | |
| @@ -1671,6 +1657,30 @@ bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, cons · 610 unmodified lines | ||
| 1671 | 1657 | return aaBox.findCapsulePenetration(start, end, radius, penetration); |
| 1672 | 1658 | } |
| 1673 | 1659 | |
| 1660 | +void EntityScriptingInterface::getMeshes(QUuid entityID, QScriptValue callback) { | |
| 1661 | + PROFILE_RANGE(script_entities, __FUNCTION__); | |
| 1662 | + | |
| 1663 | + EntityItemPointer entity = static_cast<EntityItemPointer>(_entityTree->findEntityByEntityItemID(entityID)); | |
| 1664 | + if (!entity) { | |
| 1665 | + qCDebug(entities) << "EntityScriptingInterface::getMeshes no entity with ID" << entityID; | |
| 1666 | + QScriptValueList args { false, false }; | |
| 1667 | + callback.call(QScriptValue(), args); | |
| 1668 | + return; | |
| 1669 | + } | |
| 1670 | + | |
| 1671 | + MeshProxyList result; | |
| 1672 | + bool success = entity->getMeshes(result); | |
| 1673 | + | |
| 1674 | + if (success) { | |
| 1675 | + QScriptValue resultAsScriptValue = meshesToScriptValue(callback.engine(), result); | |
| 1676 | + QScriptValueList args { resultAsScriptValue, true }; | |
| 1677 | + callback.call(QScriptValue(), args); | |
| 1678 | + } else { | |
| 1679 | + QScriptValueList args { callback.engine()->undefinedValue(), false }; | |
| 1680 | + callback.call(QScriptValue(), args); | |
| 1681 | + } | |
| 1682 | +} | |
| 1683 | + | |
| 1674 | 1684 | glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) { |
| 1675 | 1685 | glm::mat4 result; |
| 1676 | 1686 | if (_entityTree) { |