History

change Model api in anticipation of more than just PolyVox being able to give meshes to javascript

Seth Alves committed 9 years ago

Commit ce9bb431 parent b5786be10 files · +52 −59Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 10 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+25−15
@@ -21,6 +21,7 @@ · 20 unmodified lines
21#include <VariantMapToScriptValue.h>21#include <VariantMapToScriptValue.h>
22#include <SharedUtil.h>22#include <SharedUtil.h>
23#include <SpatialParentFinder.h>23#include <SpatialParentFinder.h>
24#include <model/MeshProxy.h>
24 25
25#include "EntitiesLogging.h"26#include "EntitiesLogging.h"
26#include "EntityActionFactoryInterface.h"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
1043void 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
1058bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {1044bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {
1059 PROFILE_RANGE(script_entities, __FUNCTION__);1045 PROFILE_RANGE(script_entities, __FUNCTION__);
1060 1046
@@ -1671,6 +1657,30 @@ bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, cons · 610 unmodified lines
1671 return aaBox.findCapsulePenetration(start, end, radius, penetration);1657 return aaBox.findCapsulePenetration(start, end, radius, penetration);
1672}1658}
1673 1659
1660void 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
1674glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) {1684glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) {
1675 glm::mat4 result;1685 glm::mat4 result;
1676 if (_entityTree) {1686 if (_entityTree) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t