Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Voxels inserted only when they differ from the existing ones http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=194 |
Page 1 of 1 |
Author: | kattle87 [ Sat Apr 09, 2011 3:49 pm ] |
Post subject: | Voxels inserted only when they differ from the existing ones |
Every time you try to save a voxel by setVoxelAt function, polyvox checks if the voxel was actually modified before effectively saving it. Don't you think it's a bit wasteful doing this kind of check instead of just writing the data back to the volume? I mean, I know that probably some work must be done and it could be avoided if the voxel wasn't changed, but I guess most of the time the voxel is just gonna be saved because if the programmer called that function, he meant to _do_ some modifications. Doing all of those checks might waste some CPU time and HELL, I SPENT HALF AN HOUR LOOKING FOR A BUG JUST BECAUSE MY OPERATOR == WAS NOT KEEPING INTO ACCOUNT ONE VARIABLE OF THE STRUCT ![]() ![]() My voxels store one quantity (let's say, "how much stuff is in there") and the kind of voxel (for example, air, oil, water). What happened is that the volume wasn't updating because the operator == was not checking for the "how much stuff" variable, but just for the "what is in there" one. Apart from me being a bit "stupid", I think that just straight copying might work just better and faster. Any thoughts? |
Author: | David Williams [ Sun Apr 10, 2011 6:20 pm ] |
Post subject: | Re: Voxels inserted only when they differ from the existing |
The behaviour you describe was only in the old version of the Volume class - it has already been removed from the new version supporting RLE/paging. That said, there was some good logic behind the mechanism, as described by a comment in the code: Code: //It's quite possible that the user might attempt to set a voxel to it's current //value. We test for this case firstly because it could help performance, but more //importantly because it lets us avoid unsharing blocks unnecessarily. The point is that the old system would allow several different blocks to point at the same area of memory if their contents were identical (usually for homogenous and/or empty blocks). Hence setting a voxel could have some cost as the blocks would no longer be identical and so would have to be unshared/duplicated. But overall it wasn't a great system , which is why it was replaced by the RLE stuff. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |