| Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
| Polyvox to Ogre Mesh http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=387 |
Page 3 of 4 |
| Author: | drwbns [ Mon Jun 18, 2012 12:45 am ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
That's what I'm saying. I'm only updating necessary regions and neighboring regions along with checking for duplicate region updates but I have yet to come up with the code for actually checking if the affected voxels are on the edge of a region liked you suggested. It's seems to take quite a bit of cpu time to draw a significant amount of regions all at once. For example - 7 x 6 x 3 regions = 126 regions = 4128768 voxels. if 1 region is 32 x 32 x 32 voxels, it takes just under a minute a half to draw all the regions |
|
| Author: | drwbns [ Mon Jun 18, 2012 2:44 am ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
I found an interesting bug that may be causing some problems. Code: Math::Floor(raycastResult.intersectionVoxel.getX() / divisor),Math::Floor(raycastResult.intersectionVoxel.getY() / divisor),Math::Floor(raycastResult.intersectionVoxel.getZ() / divisor) gives a different result than my ogre raycast point ( no voxels hit / freespace ) Code: myPoint = Vector3(Math::Floor(myPoint.x),Math::Floor(myPoint.y),Math::Floor(myPoint.z)); Math::Floor(myPoint.x / divisor),Math::Floor(myPoint.y / divisor),Math::Floor(myPoint.z / divisor) For example. a Y value below 0 should be in the -1 region, but when hitting a voxel and using the intersection, a voxel Y value below 0 is also 0, when it should also be -1 |
|
| Author: | David Williams [ Tue Jun 19, 2012 8:34 am ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
drwbns wrote: For example - 7 x 6 x 3 regions = 126 regions = 4128768 voxels. if 1 region is 32 x 32 x 32 voxels, it takes just under a minute a half to draw all the regions So it takes about 200ms to extract each 32x32x32 region? This does sound a little slow but it can depend on you hardware of course. Have a read of this thread (viewtopic.php?f=14&t=401) where I state that I can extract a 64x64x64 region in about 52ms. You should ue the timing tricks discused in that thread to determine whether the time is being used by the call to execute() or by something else, such as uploading the data to the GPU. drwbns wrote: I found an interesting bug that may be causing some problems. The PolyVox raycast returns an integer position (the centre of the voxel), where as the Ogre code returns a float position on the mesh. The mesh doesn't pass through the centre of the voxel, it surrounds it. Actually, the Ogre raycast is probably using the bounding box for it detection rather than going to polygon level, so this will make it even more different. Also, in your sample code it's not clear what 'divisor' is. Is it an integer? If so you're doing integer division and then taking the floor of the result which doesn't make much sense. |
|
| Author: | ker [ Tue Jun 19, 2012 8:59 am ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
it will take longer to extract a region if the sidelength is lower than the region size. Then there will be 8 or more internal chunks per region that you extract, causing a huge number of region swaps per extracted region. make sure you set the sidelength to 32 in your case (i remember the default being 16 at some time in the past) |
|
| Author: | drwbns [ Tue Jun 19, 2012 3:53 pm ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
I forgot to post that I'm actually flooring the float numbers from my Ogre raycast. I edited my post above. Divisor is an int, should I make it unsigned? I'm not sure what ker is talking about as far as the sidelength. Divisor is a set 32. I'll post back some results of using the Ogre::Timer class, thanks! |
|
| Author: | ker [ Wed Jun 20, 2012 10:38 am ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
i meant the last parameter of the largevolume constructor. it defaults to 32 in the current git, so that should not be your problem. how do you compute the lowerCorner and upperCorner of your regions? maybe they don't match up with the internal regions? internal regions go from 0,0,0 to 31,31,31 and 32, 0, 0 to 63,31,31 and so on... if you go any further than that in your extraction, you will cause internal region swaps which will definitely slow down extraction. |
|
| Author: | drwbns [ Wed Jun 20, 2012 12:27 pm ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
I'm just taking the Ogre raycast hitPoint and dividing it by 32 which gives me what region it is. Then I just multiply the region by the divsor again to give me the lowerCorner, then add 32 to the lowerCorner to give me the upperCorner. So a hitPoint of 31,31,31 would be in region 0,0,0 and 32,32,32 would be in region 1,1,1 |
|
| Author: | David Williams [ Wed Jun 20, 2012 1:15 pm ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
It's definitely worth determining whether extraction is actually the problem, by putting timing calls around the call to 'execute()' when generating the mesh. If the individual calls are indeed slow then this may because of the kind of issues that ker is suggesting. You can try swapping LargeVolume for Simple/RawVolume to determine if this is indeed the case. If the individual calls are not slow then you need to look elsewhere for you problem (perhaps GPU upload issues). |
|
| Author: | ker [ Thu Jun 21, 2012 7:12 am ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
drwbns wrote: I'm just taking the Ogre raycast hitPoint and dividing it by 32 which gives me what region it is. Then I just multiply the region by the divsor again to give me the lowerCorner, then add 32 to the lowerCorner to give me the upperCorner. So a hitPoint of 31,31,31 would be in region 0,0,0 and 32,32,32 would be in region 1,1,1 this will not work for negative positions, if you use integer division! -10,-10,-10 -> 0, 0, 0 while position 10, 10, 10 would also be in zone 0, 0, 0... maybe something is computed badly there... but yes, first test as david suggested... check which part of the extraction takes up how much time. |
|
| Author: | drwbns [ Sat Jun 23, 2012 1:57 am ] |
| Post subject: | Re: Polyvox to Ogre Mesh |
Hi ker, yes I figured that out a couple of days ago so I ended up adding -32 to coordinates that are negative to seperate the regions. I still have to run the execute timer tests so I'll post back when I've got them. Thanks |
|
| Page 3 of 4 | All times are UTC |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|