Jump to content
  • Advertisement
Sign in to follow this  
iron_poopshoot

OptimizeInplace kills my mesh

This topic is 5415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I call OptimizeInplace it kills my mesh. It's like the vb gets assigned new random values or something. When I comment out the OptimizeInplace call it looks just fine. Here is what the call looks like:
g_Mesh->OptimizeInplace(D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_STRIPREORDER, adj, NULL, NULL, NULL);
Is there anything wrong with that statment or does anyone have any ideas what could be wrong? thanks, Darren

Share this post


Link to post
Share on other sites
Advertisement
I just found out I'm getting a memory error, so I lowered my polygon count from 19602 down to 1152 and I still get the error. I have 512 MB of ram. Does this make any sense?

Share this post


Link to post
Share on other sites
Just thought I'd clarify. By memory error I mean that OptimizeInplace returns E_OUTOFMEMORY. Also I tryed it on my desktop that has 1024MB of ram and it still returns E_OUTOFMEMORY with a polygon count of 32. I'm not even rendering anything else or creating any other meshes.

Share this post


Link to post
Share on other sites
It can return out of memory if the heap is smashed because of some other, unrelated, memory overwriting bug.

I would sprinkle calls to check the heap throughout the code, especially right before and right after the call to OptimizeInPlace().

First, make sure you are linking multi-threaded debug DLL C libraries (it's an option in the project settings).

Then, add code like this:


#include <assert.h>
extern "C" int _CrtCheckMemory();

...
assert( _CrtCheckMemory() );
DoSomething();
assert( _CrtCheckMemory() );



If a check fails, then you know that the heap has gotten smashed somewhere before that call to assert().

Share this post


Link to post
Share on other sites
I changed it so I'm linking multi-threaded debug DLL C libraries and that made no difference. I placed those asserts in there to, and none of them fail. I also tried compiling a release version instead of debug and that didn't help either.

Share this post


Link to post
Share on other sites
I have similiar problem before, and I find out that it is because my mesh internal structure is mess up. I mean when I load the mesh, the vertex and index is mess up. So, may be you can check whether your mesh data is correct. Wish it help!

Nachi

Share this post


Link to post
Share on other sites
The mesh is fine. When I render it without calling OptimizeInplace it works fine and looks the way it is supposed to. I also went through my code to generate it (a simple height map) it all looks fine.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!