C++ Initializing Havok OpenGL breakpoint issue

C++ Initializing Havok OpenGL breakpoint issue

Jose的头像

Hey guys.  I have a problem when it comes to initializing Havok to OpenGL.  I have it initialize but the problem is that when I run my project, it says that my .exe has triggered a breakpoint.  The breakpoint happens after the m_world->stepDeltaTime(dt);.  I have the latest version of Havok without SIMD but even so I had to dig in there and enable SIMD anyways because I kept getting an error saying something about g_vectorContraints.  Enabling it fixes that issue.  But anyways this breakpoint I get doesnt happen all the time but when it does, I press the break button on the window it pops up and then I press F5, and it still runs fine and collides with other objects.  I just hate seeing that breakpoint message most of the time that I run it.  So here is how I initialize havok.

here is my header.

#ifndef _HAVOK_UTILITIES_
#define _HAVOK_UTILITIES_
// Math and base includes
#include <Common/Base/hkBase.h>
#include <Common/Base/System/hkBaseSystem.h>
#include <Common/Base/System/Error/hkDefaultError.h>
#include <Common/Base/Memory/System/hkMemorySystem.h>
#include <Common/Base/Memory/System/Util/hkMemoryInitUtil.h>
#include <Common/Base/Memory/Allocator/Malloc/hkMallocAllocator.h>
#include <Common/Base/Thread/Job/ThreadPool/Cpu/hkCpuJobThreadPool.h>
#include <Physics/Dynamics/World/hkpWorld.h>
#include <Physics/Collide/Dispatch/hkpAgentRegisterUtil.h>
#include <stdio.h>
class HavokUtilities
{
public:
    HavokUtilities();
    ~HavokUtilities(void);
    void StepSimulation(float dt);
    hkpWorld* GetWorld();
private:
    void InitHavok();
    void InitMemory();
    void InitPhysicsWorld();
    void DeInitHavok();
    void StepPhysicsSimulation(float dt);
    hkpWorldCinfo m_pWorldInfo;
    hkpWorld* m_world;
};
#endif

here is my source cpp

#include "HavokUtilities.h"
// Keycode
#include <Common/Base/keycode.cxx>
#undef HK_FEATURE_PRODUCT_AI
#define HK_FEATURE_PRODUCT_PHYSICS
#undef HK_FEATURE_PRODUCT_ANIMATION
#undef HK_FEATURE_PRODUCT_CLOTH
#undef HK_FEATURE_PRODUCT_DESTRUCTION
#undef HK_FEATURE_PRODUCT_BEHAVIOR
#define HK_FEATURE_REFLECTION_PHYSICS
#define HK_CLASSES_FILE <Common/Serialize/Classlist/hkClasses.h>
#define HK_EXCLUDE_FEATURE_MemoryTracker
#define HK_EXCLUDE_FEATURE_SerializeDeprecatedPre700
#define HK_EXCLUDE_FEATURE_RegisterVersionPatches 
#define HK_EXCLUDE_LIBRARY_hkGeometryUtilities
#include <Common/Base/Config/hkProductFeatures.cxx>
static void HK_CALL errorReport(const char* msg, void* userArgGivenToInit)
{
     printf("%s", msg);
}
HavokUtilities::HavokUtilities()
{
     InitHavok();
}
HavokUtilities::~HavokUtilities(void)
{
    DeInitHavok();
}
void HavokUtilities::InitHavok()
{
     InitMemory();
     InitPhysicsWorld();
}
void HavokUtilities::InitMemory()
{
    hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault(hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo(1024 * 1024));
    hkBaseSystem::init(memoryRouter, errorReport);
}
void HavokUtilities::InitPhysicsWorld()
{
    m_pWorldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_REMOVE_ENTITY;
    m_pWorldInfo.m_gravity.set(0, -9.8f, 0);
    m_pWorldInfo.m_collisionTolerance = 0.5f;
    m_pWorldInfo.setBroadPhaseWorldSize(1000.0f);
    m_pWorldInfo.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM);
    m_world = new hkpWorld(m_pWorldInfo);
    m_world->lock();
   hkpAgentRegisterUtil::registerAllAgents(m_world->getCollisionDispatcher());
   m_world->unlock();
}
void HavokUtilities::DeInitHavok()
{
   m_world->removeReference();
   hkBaseSystem::quit();
   hkMemoryInitUtil::quit();
}
void HavokUtilities::StepSimulation(float dt)
{
  m_world->lock();
  StepPhysicsSimulation(dt);
  m_world->unlock();
}
void HavokUtilities::StepPhysicsSimulation(float dt)
{
   m_world->stepDeltaTime(dt);
}
hkpWorld* HavokUtilities::GetWorld()
{
    return m_world;
}

Any help will ne appreciated.  Thanks guys.

10 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
havok_joe的头像

Hi Jose:

You got a compile(or link) error on "g_vectorConstants" with "NO SIMD", not "g_vectorContraints", is it correct? Can you show me the error message?
I think it is not a code problem. Your code looks fine for me. You should check the Configuration Properties for the project to see if there is any wrong settings. Maybe you added some conflict settings when you integrate with openGL. If you are using No SIMD version, you should make sure
HK_CONFIG_SIMD=2; WIN32; _WIN32 are in your Preprocessor Definitions. And "Enable Enhanced Instruction Set" = "Not Set"

And how do you switch "No SIMD" version to "SIMD" version? Just set HK_CONFIG_SIMD=1 ? If you want to use SIMD version, you should download our SIMD version project from our website and use SIMD version libraries. And there are some related settings as well.

I suggest you can start integrating openGL base on one of our standalone demo project file, for example:
Demo\StandAloneDemos\StepByStep\Physics\Physics_win32_vs2010_noSimd.vcxproj
to just make sure all project settings are correct.

Cheers

Joe

Joe Developer Support Engineer Havok www.havok.com
Jose的头像

Hi havok_joe:

Thanks for the reply. Yes I actually meant g_vectorConstants. Well in the hkConfigSimd.h, at the very top I did this:


#ifndef HK_CONFIG_SIMD
	// win32

#		if defined (HK_PLATFORM_X64) || defined(HK_PLATFORM_SIM)

#			define HK_CONFIG_SIMD HK_CONFIG_SIMD_ENABLED

#		else

			// x86

#			define HK_CONFIG_SIMD HK_CONFIG_SIMD_ENABLED

#		endif

Which was one of the ways to fix this g_vectorConstants error. Anyways I did what you told me to do in the Preprocessor Definitions and I also reverted the hkConfigSimd.h back to how it was initially and I get that error with the g_vectorConstants.

error LNK2001: unresolved external symbol "struct hkQuadReal const * const g_vectorConstants" (?g_vectorConstants@@3QBUhkQuadReal@@B)

havok_joe的头像

Hi Jose:

Can you make sure you linked with correct "No SIMD" version libraries?

In my test project, I set HK_CONFIG_SIMD=2 , and linked with "SIMD" version libraries by manually set the Additional Library Directories, I got the same link error as you did.

If you are not sure which version you are using, you can open Demo/Demos/Demos_win32_vs2010.vcxproj , and check the setting in "Preprocessor Definitions" to see if HK_CONFIG_SIMD=1 or not. Also, in Lib\win32_vs2010\debug_multithreaded_dll, the size of hkBase.lib for SIMD version is: 20928kb, and for "NO SIMD" version, the size is 21345kb.

Hope it is helpful

Joe Developer Support Engineer Havok www.havok.com
havok_joe的头像

By the way, if you can compile and link the project, but still got the breakpoint, could you please compile a debug_multithreaded or debug_multithreaded_dll version and try to locate the break point? We included the pdb files in those versions and it can help you gather more helpful infos,

Joe Developer Support Engineer Havok www.havok.com
Jose的头像

Sorry for the late reply been busy at school. But anyways I actually did have a problem with the libs files I had. They were the SIMD version while I was using the No SIMD one. So that fixed my g_vectorConstant issue. Thanks for pointing that out. But this still doesnt fix the breakpoint. Since it happens in the stepDeltaTime, would the problem occur if deltatime is 0? When my program starts deltatime is 0. I also have another problem, I am not able to call these quit functions in my destructor:

hkBaseSystem::quit();
hkMemoryInitUtil::quit();

It tells me Access Violation. Do I even need to call these?

havok_joe的头像

Hi:

1) You do not need to add lock() before StepPhysicsSimulation and unlock() after it because we actually did this inside stepDeltaTime() call.

2) You must give deltatime a value, it can be 1/30, 1/60, or 1/120. I doubt why you did not get an assert if you set deltatime to 0.
Please refer to the documentation "Havok Physics \ 2.3. Stepping the Simulation"

3) If you still got breakpoint, please compile it in debug_multithreaded(_dll) mode, and give me the output and call stack, and I can have a look.

4) You should call hkBaseSystem::quit() and hkMemoryInitUtil::quit() , otherwise, it will cause memory leak. But you must make sure they are being called at the end of the application. At least after all havok related values have been actually deleted. It is a bit danger to put them in a destructor because some of the class members will probably be released after the destructor base on the C++ definition.

5) I suggest you can put those two line at the end of the main function and then test it. If you still have problem, please paste the call stack and output here.

Cheers

Joe Developer Support Engineer Havok www.havok.com
Jose的头像

Alright the breakpoint issue is gone. I use my own deltatime which uses the QueryPerformanceFrequency which is why it started at zero but now that its not zero its fixed I hope. Now its just the last issue. At first I was deleting havok stuff first but then I switch the order so that it deletes it at the end but it still doesnt fix it. This is the call stack:

Yellow Arrow -> Demo3Proj.exe!hkpMtThreadStructure::`scalar deleting destructor'() + 0x6c bytes C++
Demo3Proj.exe!hkpWorld::~hkpWorld() Line 225 C++
Demo3Proj.exe!hkpWorld::`scalar deleting destructor'() + 0xb bytes C++
Demo3Proj.exe!hkReferencedObject::removeReference() Line 190 + 0x8 bytes C++
Green Arrow -> Demo3Proj.exe!HavokUtilities::DeInitHavok() Line 80 C++
Demo3Proj.exe!HavokUtilities::~HavokUtilities() Line 45 C++
Demo3Proj.exe!HavokUtilities::`scalar deleting destructor'() + 0x14 bytes C++
Demo3Proj.exe!Utility::SafeDelete(HavokUtilities * & p) Line 39 + 0x1e bytes C++
Demo3Proj.exe!GameWorld::~GameWorld() Line 29 + 0xe bytes C++
Demo3Proj.exe!`dynamic atexit destructor for 'g_gameWorld''() + 0x13 bytes C++
msvcr100d.dll!doexit(int code, int quick, int retcaller) Line 567 C
msvcr100d.dll!exit(int code) Line 393 + 0xd bytes C
Demo3Proj.exe!__tmainCRTStartup() Line 568 C
Demo3Proj.exe!WinMainCRTStartup() Line 371 C
kernel32.dll!7578339a()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!777e9ef2()
ntdll.dll!777e9ec5()

Output:

'Demo3Proj.exe': Loaded 'C:\Users\Jose\Desktop\SVN\Demo3\Demo3Proj\Debug(debug_multithreaded_dll)\Demo3Proj.exe', Symbols loaded.
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\opengl32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\glu32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Users\Jose\Desktop\SVN\Demo3\Demo3Proj\Demo3Proj\glew32.dll', Binary was not built with debug information.
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\wsock32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Program Files\WIDCOMM\Bluetooth Software\syswow64\BtMmHook.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\psapi.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\clbcatq.dll', Cannot find or open the PDB file
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\nvoglv32.dll', Cannot find or open the PDB file
The thread 'Win32 Thread' (0x14cc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1c2c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x282c) has exited with code 0 (0x0).
'Demo3Proj.exe': Loaded 'C:\Windows\SysWOW64\dbghelp.dll', Cannot find or open the PDB file
DBGHELP: Symbol Search Path: .
First-chance exception at 0x013061fc in Demo3Proj.exe: 0xC0000005: Access violation reading location 0x0000002c.
Unhandled exception at 0x013061fc in Demo3Proj.exe: 0xC0000005: Access violation reading location 0x0000002c.

havok_joe的头像

It looks like the havok memory system has already been released before releasing some internal member in hkpWorld.
Instead of calling "hkBaseSystem::quit(); hkMemoryInitUtil::quit();" in the destructor function, can you move them to the very end of your main function? And then test if you still have problem or not.

Joe Developer Support Engineer Havok www.havok.com
Jose的头像

Putting it at the end of the main worked like a charm. Thanks havok_joe. Appreciate the help.

登陆并发表评论。