It is currently Sat Aug 08, 2020 8:46 pm


All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [resolved] Raycast::doRaycast: abs is for int with gcc
PostPosted: Thu Jan 05, 2012 1:27 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
inside Raycast::doRaycast there are 6 instances of abs used on float that should be std::abs.
otherwise the values get "floor"ed, too as the get cast to int and back.

Changing it to std::abs works fine here and fixes some nasty bugs I had with the raycaster.


Last edited by ker on Sat Jan 07, 2012 12:45 pm, edited 1 time in total.

Top
Offline Profile  
Reply with quote  
 Post subject: Re: Raycast::doRaycast: abs is for int with gcc
PostPosted: Thu Jan 05, 2012 1:56 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
So if you don't use the std:: prefix, which abs() function is it picking up instead? The C version? Is the wrong header being included, or is it getting it from a header included in your own project? Sorry, I don't have the code in front of me...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Raycast::doRaycast: abs is for int with gcc
PostPosted: Thu Jan 05, 2012 2:15 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
it takes the one from stdlib.h which is probably "
extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;"
at least netbeans tells me this inside of my project.

I put debug messages into Raycast.inl which showed that an int casting or sth similar happened.
after putting std:: infront, those debug messages showed that it's a proper "float abs"

I did this inside the BasicExample, so it's not my project messing around here.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Raycast::doRaycast: abs is for int with gcc
PostPosted: Thu Jan 05, 2012 9:08 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
No problem, I've fixed it (though I'll leave you to test). I also replaced abs() with std::abs() in a few other places.

The actual problem was probably that the C version of abs() is only for integer values... for floats you are supposd to use fabs(). In C++ this is resolved with function overloading.

Please confirm if it works now as I don't have a good test case.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Raycast::doRaycast: abs is for int with gcc
PostPosted: Fri Jan 06, 2012 6:53 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
yes it works great now.
here you can see the result: vertex based lighting brought to you by PolyVox::Raycast (combined with a pixel shader for preciser lighting w/o shadows)

Attachment:
screenshot01052012_143828698.jpg
screenshot01052012_143828698.jpg [ 48.69 KiB | Viewed 4522 times ]


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Raycast::doRaycast: abs is for int with gcc
PostPosted: Sun Jan 08, 2012 7:11 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
ker wrote:
here you can see the result: vertex based lighting brought to you by PolyVox::Raycast (combined with a pixel shader for preciser lighting w/o shadows)


Wow, that works surprisingly well :-) I'd be interested to see how it looked in a more complex scene so keep up up to date on this. Does it take long to compute? The Raycast is also used by the AmbientOcclusionCalculator but it casts a lot more rays and is currently too slow I think.

On that topic, the Linux nightly regression tests for the AmbientOcclusionCalculator have started failing since this change. It might be a good thing as the Linux results were always different from the Windows ones and I never new why. Perhaps it was this use of abs(). Just bought my new laptop so once it's set up I'll see if it's now consistent.


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 1 guest


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