It is currently Sat Aug 22, 2020 4:29 am


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Where does the intersectionVoxel go in .21 version?
PostPosted: Thu Mar 21, 2013 12:41 pm 

Joined: Fri Sep 10, 2010 5:38 am
Posts: 30
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 ?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Where does the intersectionVoxel go in .21 version?
PostPosted: Thu Mar 21, 2013 8:30 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Where does the intersectionVoxel go in .21 version?
PostPosted: Fri Mar 22, 2013 10:57 am 

Joined: Fri Sep 10, 2010 5:38 am
Posts: 30
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Where does the intersectionVoxel go in .21 version?
PostPosted: Fri Mar 22, 2013 1:53 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Where does the intersectionVoxel go in .21 version?
PostPosted: Sat Mar 23, 2013 12:44 pm 

Joined: Fri Sep 10, 2010 5:38 am
Posts: 30
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Where does the intersectionVoxel go in .21 version?
PostPosted: Sun Mar 24, 2013 8:18 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net