diff --git a/include/PolyVox/Picking.h b/include/PolyVox/Picking.h index 6f92a859..c95f11e0 100644 --- a/include/PolyVox/Picking.h +++ b/include/PolyVox/Picking.h @@ -34,9 +34,10 @@ namespace PolyVox */ struct PickResult { - PickResult() : didHit(false) {} + PickResult() : didHit(false), hasPreviousVoxel(false) {} bool didHit; ///< Did the picking operation hit anything 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 }; diff --git a/include/PolyVox/Picking.inl b/include/PolyVox/Picking.inl index c876d935..6ba852e8 100644 --- a/include/PolyVox/Picking.inl +++ b/include/PolyVox/Picking.inl @@ -56,6 +56,7 @@ namespace PolyVox return false; } + m_result.hasPreviousVoxel = true; m_result.previousVoxel = sampler.getPosition(); return true; diff --git a/tests/TestPicking.cpp b/tests/TestPicking.cpp index 596cac04..a3d26d6e 100644 --- a/tests/TestPicking.cpp +++ b/tests/TestPicking.cpp @@ -59,6 +59,7 @@ void TestPicking::testExecute() QCOMPARE(resultHit.didHit, true); 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)); PickResult resultMiss = pickVoxel(&volData, Vector3DFloat(0, uVolumeSideLength / 2, uVolumeSideLength / 2), Vector3DFloat(uVolumeSideLength / 2, uVolumeSideLength, uVolumeSideLength), emptyVoxelExample);