Jump to content
  • Advertisement
Sign in to follow this  
karsnen

to delete a mesh

This topic is 2705 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

ppl,

I am loading a simple mesh file on the terrain. On collision I have to delete or destroy it.

Could someone pls help me out with this issue?

Sincerely karsnen.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

Write a macro like that:
#define _RELEASE_COM_(x) if( (x) != NULL) { (x)->Release(); (x) = NULL; }

And use it on collide:
if (MyMeshCollides)
_RELEASE_COM_(pMyMesh);


And in rendering function, check whether it's NULL or not:
if (pMyMesh != NULL)
RenderMyMesh();


hth.
-R

Share this post


Link to post
Share on other sites
@programci_84: You can and should use an inline function instead of a macro. In modern C++, the preprocessor is for conditional compilation, most other uses are discouraged to the point of effective deprecation.

Note that your macro evaluates it's argument multiple times, which could be problematic. Also it uses a reserved name, all names beginning with an underscore followed by an uppercase letter are reserved for the compiler, as are ones beginning with two underscores and identifiers beginning with a single underscore in the global namespace.

Something like this would be better:

inline void SafeRelease(IUnknown *& pointer)
{
if(pointer)
{
pointer->Release();
pointer = 0;
}
}

Share this post


Link to post
Share on other sites
@programci_84 & @ rip-off


Thank you. I will work it out and come back to you again. Actually I am having trouble in lighting. It seems that I have initialized two instances.


Source:
http://codepad.org/6siGDAy0

I hope you guys can understand it. If you guys could help. It would be really great.

Thank you.

Karsnen.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!