[SOLVED] Is my code wrong or my Item.hkt file I create with Contenet Tools

[SOLVED] Is my code wrong or my Item.hkt file I create with Contenet Tools

Portrait de TediCreations

Hello,

I have made a Singleton pattern design that initialises HAVOK and does all the work for me.

I can create spheres, boxes etc etc

But I can not create a rigidBody from from a .hkt file

When I try to do that I get debug error.

So my question is:

Is my code wrong or my Item.hkt file I create with Contenet Tools

Here is my code.

P.S: I use Visual Studio 2010, HavokContentTools_2012-1-0_20120817_32Bit_PcXs and Havok_Physics_Animation_2012-1-0_PC_XS_win32_VS2010_noSimd_keycode_perpetual_20120831

Thank you for your time.

Fichier attachéTaille
Téléchargement item.zip45.78 Ko
http://reallibrary.juplo.com/ Real Library SDK is a C++ toolbox that can create virtual reality worlds.
5 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.
Portrait de Havok - Josh S.

Hi TediCreations,

I can't say for sure without knowing what specific debug error you are getting, but it looks like you are disposing of objects too soon. Please look at lines 65-76 in your sample. Both of these objects should be persistent, which means the calls to removeReference may be the source of your problem. removeReference is used for reference counted objects on the heap, and once an object's reference count reaches 0 the object is garbage collected. It's not clear in your example how you manage the physics world's lifecycle, but make sure you are not removing the last reference too soon. Also, your loaded data contains your rigid bodies which are used directly by the physics world, so it should persist as long as its objects are used. For this reason, it's probably also a good idea to keep a pointer to m_loadedData so you can clean it up later. Please take a look at the Common Havok Concepts help documentation under Base Library -> The Base System -> Reference Counting for more details.

Cheers,
Josh

Josh S. Havok Developer Support Engineer www.havok.com
Portrait de TediCreations

Hi Josh,

Thanks for answering me. I changed my code from a function to a class. Here it is -> http://pastie.org/5463030
I can build the program.

The debug error I get is in line 43.
PHYSICSDEVICE.getWorld()->addPhysicsSystem( physicsData->getPhysicsSystems()[i] );

When I load an other .hkt file I get a debug error in line 35.
HK_ASSERT2(0xa6451544, physicsData != HK_NULL, "Could not find physics data in root level object" );

It never reaches the destructor where I dispose of the object.

I try to explain it the best I can.

Thanks
Elias

http://reallibrary.juplo.com/ Real Library SDK is a C++ toolbox that can create virtual reality worlds.
Portrait de Havok - Josh S.

Hi Elias,

what is the debug error you get at line 43? I am able to run fine with your hkt file.

Josh S. Havok Developer Support Engineer www.havok.com
Portrait de TediCreations

Well I solved the problem with this code.

Thanks.

http://reallibrary.juplo.com/ Real Library SDK is a C++ toolbox that can create virtual reality worlds.

Connectez-vous pour laisser un commentaire.