Added ability to check whether previousVoxel has been set.

This commit is contained in:
David Williams 2016-05-21 08:34:13 +01:00
parent f4c4bf984c
commit 9a71004b1e
3 changed files with 4 additions and 1 deletions

View File

@ -34,9 +34,10 @@ namespace PolyVox
*/ */
struct PickResult struct PickResult
{ {
PickResult() : didHit(false) {} PickResult() : didHit(false), hasPreviousVoxel(false) {}
bool didHit; ///< Did the picking operation hit anything bool didHit; ///< Did the picking operation hit anything
Vector3DInt32 hitVoxel; ///< The location of the solid voxel it hit Vector3DInt32 hitVoxel; ///< The location of the solid voxel it hit
bool hasPreviousVoxel; //< Whether there is a previous voxel (there may not be if the raycast started in a solid object).
Vector3DInt32 previousVoxel; ///< The location of the voxel before the one it hit Vector3DInt32 previousVoxel; ///< The location of the voxel before the one it hit
}; };

View File

@ -56,6 +56,7 @@ namespace PolyVox
return false; return false;
} }
m_result.hasPreviousVoxel = true;
m_result.previousVoxel = sampler.getPosition(); m_result.previousVoxel = sampler.getPosition();
return true; return true;

View File

@ -59,6 +59,7 @@ void TestPicking::testExecute()
QCOMPARE(resultHit.didHit, true); QCOMPARE(resultHit.didHit, true);
QCOMPARE(resultHit.hitVoxel, Vector3DInt32((uVolumeSideLength / 2) + 1, uVolumeSideLength / 2, uVolumeSideLength / 2)); QCOMPARE(resultHit.hitVoxel, Vector3DInt32((uVolumeSideLength / 2) + 1, uVolumeSideLength / 2, uVolumeSideLength / 2));
QCOMPARE(resultHit.hasPreviousVoxel, true);
QCOMPARE(resultHit.previousVoxel, Vector3DInt32((uVolumeSideLength / 2), uVolumeSideLength / 2, uVolumeSideLength / 2)); QCOMPARE(resultHit.previousVoxel, Vector3DInt32((uVolumeSideLength / 2), uVolumeSideLength / 2, uVolumeSideLength / 2));
PickResult resultMiss = pickVoxel(&volData, Vector3DFloat(0, uVolumeSideLength / 2, uVolumeSideLength / 2), Vector3DFloat(uVolumeSideLength / 2, uVolumeSideLength, uVolumeSideLength), emptyVoxelExample); PickResult resultMiss = pickVoxel(&volData, Vector3DFloat(0, uVolumeSideLength / 2, uVolumeSideLength / 2), Vector3DFloat(uVolumeSideLength / 2, uVolumeSideLength, uVolumeSideLength), emptyVoxelExample);