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

Realtime Ogre 1.8 Terrain Component manipulation
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=312
Page 12 of 13

Author:  drwbns [ Sun Feb 26, 2012 9:26 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

Ok, I changed it to just Density8 and that works but I still get error -

error C2276: '&' : illegal operation on bound member function expression

initializing it like so -

Code:
PolyVox::LargeVolume<Density8> volume(&dataRequiredHandler, &dataOverflowHandler, num_chunks);

and defined the functions like so -

Code:
void dataRequiredHandler(const PolyVox::ConstVolumeProxy<Density8>&, const PolyVox::Region&)
{}
   void dataOverflowHandler(const PolyVox::ConstVolumeProxy<Density8>&, const PolyVox::Region&)
{}

Author:  Freakazo [ Sun Feb 26, 2012 11:54 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

Not at home right now, but only difference between the way I've done it and you've done it is highlighted in bold:

void dataRequiredHandler(const PolyVox::ConstVolumeProxy<Density8>& volume, const PolyVox::Region& region)
{}

Author:  David Williams [ Mon Feb 27, 2012 10:15 am ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

I haven't used the LargeVolume much (though I hope to in our next project) so I may be wrong here... but this use of empty handlers makes me nerveous. I mean, if the volume tries to unload and then reload data then isn't it just going to get lost? Is it not better to pass '0' (like one of the constructors does) in which case the handlers won't actually get called (though I forget what happens when an overflow occurs).

Also, RawVolume and SimpleVolume should handle negative coordinates fine if you set up your initial region to include some of the negative space, but I don't think there has been much testing.

I'm just a little worried that you (drwbns) haven't quite mastered the basics, and that using LargeVolume/handlers might cause more confusion for you.

Author:  ker [ Mon Feb 27, 2012 11:08 am ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

hmm... yes data gets lost. but it would also get lost if you passed 0... which doesn't work anyway, since the deprecated constructor with 3 ints will then get called.

the problem is that drwbns used a member function of a class... but for just passing the addr of the function, those need to be free functions.

@drwbns: just move the callbacks out of your class. they do not need to be declared in the header file, just define them in the source file above the point where you use them.

@david: in my opinion largevolume just needs a default constructor (no args, infinite volumesize, no callbacks), once it has that, it is the easiest volume to use. you dump data anywhere in it and then you run any surfaceextractor on a region you know to contain data.

Author:  drwbns [ Mon Feb 27, 2012 1:44 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

Ok I moved the functions but now I get a crash on initializing the volume.

Code:
Unhandled exception at 0x76d6b9bc (KernelBase.dll) in WorldCraft.exe: Microsoft C++ exception: std::invalid_argument at memory location 0x003af664..


code stops around -

Code:
   void LargeVolume<VoxelType>::resize(const Region& regValidRegion, uint16_t uBlockSideLength)
   {
      //Debug mode validation
      assert(uBlockSideLength > 0);
      
      //Release mode validation
      if(uBlockSideLength == 0)
      {
         throw std::invalid_argument("Block side length cannot be zero.");
      }
      if(!isPowerOf2(uBlockSideLength))
      {
         throw std::invalid_argument("Block side length must be a power of two.");
      }

      m_uTimestamper = 0;


then if I continue it says -

Code:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Assertion failed!

Program: ...
File: C:\Users\Andrew\Downloads\polyvox-020...\Utility.cpp
Line: 37

Expression: isPowerOf2(uInput)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts

(Press Retry to debug the application - JIT must be enabled)
---------------------------
Abort   Retry   Ignore   
---------------------------


What size should num_chunks be?

UPDATE: I played around with the num_chunks size and at 512, the program runs but crashes after raycasting with the error -

Code:
Unhandled exception at 0x76d6b9bc (KernelBase.dll) in WorldCraft.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0028e5a0..

Author:  ker [ Mon Feb 27, 2012 2:30 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

just leave it empty, the default is fine...
512 is a little extreme ;) and it's not num_chunks it's the side length of the chunks, something internal that you do not need

Author:  drwbns [ Mon Feb 27, 2012 2:33 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

ok that works, but now I can't see my mesh anymore. What's the best way to go about generating the mesh? Do I have to change my mesh generating function?

Author:  David Williams [ Mon Feb 27, 2012 2:49 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

I think your using the term 'crash' a little loosly here ;-) It's not really crashing - it's throwing an exception to tell you you've done something wrong so you do need to pay attention to the error. It's saying:

Code:
Unhandled exception at 0x76d6b9bc (KernelBase.dll) in WorldCraft.exe: Microsoft C++ exception: std::invalid_argument at memory location 0x003af664..


This means an exception of type invalid_argument has been thrown by PolyVox - i.e. the function argument you passed was not valid. From your next code snippet:

Code:
if(!isPowerOf2(uBlockSideLength))
{
   throw std::invalid_argument("Block side length must be a power of two.");
}


This exception can be thrown if your block size is not a power of two (this is why it works for 512). There are other reasons it can be thrown, and you can handle the exception and call the 'what()' function to retrieve the actual error message (this is the same as standard C++ exceptions).

Lastly:

drwbns wrote:
UPDATE: I played around with the num_chunks size and at 512, the program runs but crashes after raycasting with the error -

Code:
Unhandled exception at 0x76d6b9bc (KernelBase.dll) in WorldCraft.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0028e5a0..


This time the exception is of type bad_alloc, which means it failed to allocate enough memory for the block. You should use a much smaller block size (maybe 32 or 64, but still a power of two!).

Author:  David Williams [ Mon Feb 27, 2012 2:54 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

ker wrote:
hmm... yes data gets lost. but it would also get lost if you passed 0...


Except in the case of it being '0' we can test for that... maybe we should consider changing the behaviour of LargeVolume so that if these handlers are not provided then it will never do paging and will just run out of memory? I can't think through this in detail at the moment as I'm focusing on other parts of PolyVox, but maybe something for the future?

ker wrote:
which doesn't work anyway, since the deprecated constructor with 3 ints will then get called.


Probably time to get rid of that constructor - it was only there to catch people who didn't update their code.

ker wrote:
in my opinion largevolume just needs a default constructor (no args, infinite volumesize, no callbacks), once it has that, it is the easiest volume to use. you dump data anywhere in it and then you run any surfaceextractor on a region you know to contain data.


I could be open to this, and I guess it also relates to my first point above.

Author:  drwbns [ Mon Feb 27, 2012 3:00 pm ]
Post subject:  Re: Realtime Ogre 1.8 Terrain Component manipulation

Since LargeVolume doesn't have a set size, how do I go about splitting it into mesh regions?

UPDATE: I just passed some initial sizes to my volumeSplitter function instead of the volume sizes and that works fine but still, my raycasts are failing on the LargeVolume, no intersection is found?

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