Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Where does the intersectionVoxel go in .21 version?
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=492
Page 1 of 1

Author:  pumpkin_zch2u [ Thu Mar 21, 2013 12:41 pm ]
Post subject:  Where does the intersectionVoxel go in .21 version?

Currently I update my project into polyvox .21 version. I found PolyVox::RaycastResult::intersectionVoxel no longer exists. does it mean that when I do the raycast query, I have to write my own callback function to fulfill the intersectionVoxel task in "raycastWithDirection" function ?

Author:  David Williams [ Thu Mar 21, 2013 8:30 pm ]
Post subject:  Re: Where does the intersectionVoxel go in .21 version?

Yes, this is correct. There is a unit test which you can look at for an example. See here:

https://bitbucket.org/volumesoffun/poly ... ster#cl-36

You can modify this code so that rather than counting the number of voxels touched it can instead keep track of the last voxel.

Author:  pumpkin_zch2u [ Fri Mar 22, 2013 10:57 am ]
Post subject:  Re: Where does the intersectionVoxel go in .21 version?

David Williams wrote:
Yes, this is correct. There is a unit test which you can look at for an example. See here:

https://bitbucket.org/volumesoffun/poly ... ster#cl-36

You can modify this code so that rather than counting the number of voxels touched it can instead keep track of the last voxel.


Thank you David. It seems to me that it is pretty a little bit hard to me to work it out. Maybe More examples are needed.

Author:  David Williams [ Fri Mar 22, 2013 1:53 pm ]
Post subject:  Re: Where does the intersectionVoxel go in .21 version?

Yes, it's very unfortunate that the documentation in the header file is out of date. That needs fixing of course. But did you get it to work or do you need another example posted here?

Author:  pumpkin_zch2u [ Sat Mar 23, 2013 12:44 pm ]
Post subject:  Re: Where does the intersectionVoxel go in .21 version?

David Williams wrote:
Yes, it's very unfortunate that the documentation in the header file is out of date. That needs fixing of course. But did you get it to work or do you need another example posted here?

If samples that have functions which are similar to intersectionVoxel, that would be pretty good.

Author:  David Williams [ Sun Mar 24, 2013 8:18 am ]
Post subject:  Re: Where does the intersectionVoxel go in .21 version?

I haven't tested but it should look something like the following:

Code:
class RaycastIntersectionFinder
{
public:
   RaycastIntersectionFinder()
   {
   }

   bool operator()(const SimpleVolume<int8_t>::Sampler& sampler)
   {
      // Store this so we can retrieve it later
      v3dLastPosition = sampler.getPosition();

      // If the ray is inside the volume then check if it has hit a solid voxel.
      if(!sampler.isCurrentPositionValid())
      {
         if(sampler.getVoxel() > 0) // You can replace this with your own condition if you want to.
         {
            // We've hit something, so stop traversing.
            return false;
         }
      }

      // By default we continue traversing.
      return true;
   }

   bool bFoundIntersection;
   Vector3DInt32 v3dLastPosition;
};


You can use that as the callback for the raycast, and it basically keeps track of the last voxel that was examined. So you can check the return result of the raycast function and if it is RaycastResults::Interupted then you know the ray hit something, and you can find out what by then checking the 'v3dLastPosition' member of the callback above.

But yeah... I'll try and add some more documentation to the class.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/