add Voxels.getFaceVector() to JS

This commit is contained in:
ZappoMan 2014-02-23 11:38:23 -08:00
parent 4e28a8c312
commit 03d6173c90
2 changed files with 21 additions and 0 deletions

View file

@ -64,3 +64,21 @@ RayToVoxelIntersectionResult VoxelsScriptingInterface::findRayIntersection(const
}
return result;
}
glm::vec3 VoxelsScriptingInterface::getFaceVector(const QString& face) {
if (face == "MIN_X_FACE") {
return glm::vec3(-1, 0, 0);
} else if (face == "MAX_X_FACE") {
return glm::vec3(1, 0, 0);
} else if (face == "MIN_Y_FACE") {
return glm::vec3(0, -1, 0);
} else if (face == "MAX_Y_FACE") {
return glm::vec3(0, 1, 0);
} else if (face == "MIN_Z_FACE") {
return glm::vec3(0, 0, -1);
} else if (face == "MAX_Z_FACE") {
return glm::vec3(0, 0, 1);
}
return glm::vec3(0, 0, 0); //error case
}

View file

@ -60,6 +60,9 @@ public slots:
/// If the scripting context has visible voxels, this will determine a ray intersection
RayToVoxelIntersectionResult findRayIntersection(const PickRay& ray);
/// returns a voxel space axis aligned vector for the face, useful in doing voxel math
glm::vec3 getFaceVector(const QString& face);
private:
void queueVoxelAdd(PacketType addPacketType, VoxelDetail& addVoxelDetails);
VoxelTree* _tree;