History

hook up a way to get mesh out of polyvox

Seth Alves committed 9 years ago

Commit d158f6a1 parent d6b22168 files · +60 −30Browse files

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

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+21−16
@@ -822,8 +822,7 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra · 821 unmodified lines
822 }822 }
823}823}
824 824
825bool EntityScriptingInterface::setVoxels(QUuid entityID,825bool EntityScriptingInterface::polyVoxWorker(QUuid entityID, std::function<bool(PolyVoxEntityItem&)> actor) {
826 std::function<bool(PolyVoxEntityItem&)> actor) {
827 if (!_entityTree) {826 if (!_entityTree) {
828 return false;827 return false;
829 }828 }
@@ -887,32 +886,38 @@ bool EntityScriptingInterface::setPoints(QUuid entityID, std::function<bool(Line · 57 unmodified lines
887 886
888 887
889bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value) {888bool EntityScriptingInterface::setVoxelSphere(QUuid entityID, const glm::vec3& center, float radius, int value) {
890 return setVoxels(entityID, [center, radius, value](PolyVoxEntityItem& polyVoxEntity) {889 return polyVoxWorker(entityID, [center, radius, value](PolyVoxEntityItem& polyVoxEntity) {
891 return polyVoxEntity.setSphere(center, radius, value);890 return polyVoxEntity.setSphere(center, radius, value);
892 });891 });
893}892}
894 893
895bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& position, int value) {894bool EntityScriptingInterface::setVoxel(QUuid entityID, const glm::vec3& position, int value) {
896 return setVoxels(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) {895 return polyVoxWorker(entityID, [position, value](PolyVoxEntityItem& polyVoxEntity) {
897 return polyVoxEntity.setVoxelInVolume(position, value);896 return polyVoxEntity.setVoxelInVolume(position, value);
898 });897 });
899}898}
900 899
901bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) {900bool EntityScriptingInterface::setAllVoxels(QUuid entityID, int value) {
902 return setVoxels(entityID, [value](PolyVoxEntityItem& polyVoxEntity) {901 return polyVoxWorker(entityID, [value](PolyVoxEntityItem& polyVoxEntity) {
903 return polyVoxEntity.setAll(value);902 return polyVoxEntity.setAll(value);
904 });903 });
905}904}
906 905
907bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3& lowPosition,906bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3& lowPosition,
908 const glm::vec3& cuboidSize, int value) {907 const glm::vec3& cuboidSize, int value) {
909 return setVoxels(entityID, [lowPosition, cuboidSize, value](PolyVoxEntityItem& polyVoxEntity) {908 return polyVoxWorker(entityID, [lowPosition, cuboidSize, value](PolyVoxEntityItem& polyVoxEntity) {
910 return polyVoxEntity.setCuboid(lowPosition, cuboidSize, value);909 return polyVoxEntity.setCuboid(lowPosition, cuboidSize, value);
911 });910 });
912}911}
913 912
914MeshProxy* EntityScriptingInterface::voxelsToMesh(QUuid entityID) {913void EntityScriptingInterface::voxelsToMesh(QUuid entityID, QScriptValue callback) {
915 return nullptr;914 polyVoxWorker(entityID, [callback](PolyVoxEntityItem& polyVoxEntity) mutable {
915 QScriptValue mesh;
916 polyVoxEntity.getMeshAsScriptValue(callback.engine(), mesh);
917 QScriptValueList args { mesh };
918 callback.call(QScriptValue(), args);
919 return true;
920 });
916}921}
917 922
918bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {923bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector<glm::vec3>& points) {