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
2121 #include <VariantMapToScriptValue.h>
2222 #include <SharedUtil.h>
2323 #include <SpatialParentFinder.h>
24+#include <model/MeshProxy.h>
2425
2526 #include "EntitiesLogging.h"
2627 #include "EntityActionFactoryInterface.h"
@@ -1040,21 +1041,6 @@ bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3 · 1013 unmodified lines
10401041 });
10411042 }
10421043
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−
10581044 bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {
10591045 PROFILE_RANGE(script_entities, __FUNCTION__);
10601046
@@ -1671,6 +1657,30 @@ bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, cons · 610 unmodified lines
16711657 return aaBox.findCapsulePenetration(start, end, radius, penetration);
16721658 }
16731659
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+
16741684 glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) {
16751685 glm::mat4 result;
16761686 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