Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
October 12, 2008 2:19 PM PDT
hkpSimpleMeshShape won't come to rest

Hey,

first of all thanks for Intel making Havok available like this. And this forum seems really great.

I've got a problem I hope you could help with. I've done a simple test project that creates two hkpSimpleMeshShapes (just boxes) from my mesh triangle data, and they appear to form correctly in the Visual Debugger, but when the box drops on the another one and is supposed to settle in to rest, it instead jumps away.

With worldInfo.m_contactRestingVelocity = 0.01f, it is even crazier.


This is what I have in worldInfo:

 

		worldInfo.m_gravity.set(0.0f, -9.8f, 0.0f);
		worldInfo.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_8ITERS_MEDIUM); 
		worldInfo.m_collisionTolerance = 0.01f;
		//worldInfo.m_contactRestingVelocity = 0.01f;

 

 

This is how I create the boxes:

 

	// Create the floor as a fixed box
	{
		hkpRigidBodyCinfo boxInfo;

		hkpSimpleMeshShape* shape2 = new hkpSimpleMeshShape( 0.1f ); 

		shape2->m_vertices.setSize( mesh2.numVertices ); 

		for(int i=0; i<mesh2.numVertices; i++)
		{
			//sprintf(str, "vertex %i: %f, %f, %f", i, mesh2.vertexList[i].p.x, mesh2.vertexList[i].p.y, mesh2.vertexList[i].p.z); cprint(str);

			shape2->m_vertices[i].set(
			mesh2.vertexList[i].p.x,
			mesh2.vertexList[i].p.y,
			mesh2.vertexList[i].p.z,
			0.0f );
		}

		//sprintf(str, "numfaces: %i", mesh.numFaces); cprint(str);

		shape2->m_triangles.setSize( mesh.numFaces );

		for(int i=0, k=0; k<mesh2.numFaces; i+=3, k++)
		{
			//sprintf(str, "faces %i: %i, %i, %i", k, mesh2.faceList[i], mesh2.faceList[i+1], mesh2.faceList[i+2]); cprint(str);

			shape2->m_triangles[k].m_a = mesh2.faceList[i+2];
			shape2->m_triangles[k].m_b = mesh2.faceList[i+1];
			shape2->m_triangles[k].m_c = mesh2.faceList[i+0];
		} 

		{
			hkpMoppCompilerInput mci;
			hkpMoppCode *moppCode = hkpMoppUtility::buildCode( shape2, mci );
			hkpMoppBvTreeShape* moppShape = new hkpMoppBvTreeShape( shape2, moppCode );
			shape2->computeWeldingInfo( moppShape, hkpWeldingUtility::WeldingType::WELDING_TYPE_ANTICLOCKWISE );
			moppCode->removeReference();
		}

		boxInfo.m_shape = shape2;
		boxInfo.m_motionType = hkpMotion::MOTION_FIXED;
		boxInfo.m_position.set(0.0f, 0.0f, 0.0f);
		boxInfo.m_restitution = 0.9f;

		g_floor = new hkpRigidBody(boxInfo);
		shape2->removeReference();

		physicsWorld->addEntity(g_floor);
		g_floor->removeReference();
	}

	// Create a moving box
	hkpSimpleMeshShape* shape = new hkpSimpleMeshShape( 0.1f ); 

	shape->m_vertices.setSize( mesh.numVertices ); 

	for(int i=0; i<mesh.numVertices; i++)
	{
		shape->m_vertices[i].set(
		mesh.vertexList[i].p.x,
		mesh.vertexList[i].p.y,
		mesh.vertexList[i].p.z,
		0.0f );
	}

	shape->m_triangles.setSize( mesh.numFaces );

	for(int i=0, k=0; k<mesh.numFaces; i+=3, k++)
	{
		shape->m_triangles[k].m_a = mesh.faceList[i+0];
		shape->m_triangles[k].m_b = mesh.faceList[i+1];
		shape->m_triangles[k].m_c = mesh.faceList[i+2];
	} 

	{
		hkpMoppCompilerInput mci;
		hkpMoppCode *moppCode = hkpMoppUtility::buildCode( shape, mci );
		hkpMoppBvTreeShape* moppShape = new hkpMoppBvTreeShape( shape, moppCode );
		shape->computeWeldingInfo( moppShape, hkpWeldingUtility::WeldingType::WELDING_TYPE_ANTICLOCKWISE );
		moppCode->removeReference();
	}

	const hkReal boxDim = 15.0f;				// This is the size of the cubes
	const hkReal extBoxDim = 1.1f * boxDim;	// This is an extended size (used to shorten the pendulums)
	
	hkVector4 boxRadii(boxDim *.5f, boxDim *.5f, boxDim *.5f);
	hkpShape* boxShape = new hkpBoxShape( boxRadii , 0 ); 
	hkpMassProperties massProperties;
	hkpInertiaTensorComputer::computeBoxVolumeMassProperties(boxRadii, 110.0f, massProperties);

	hkpRigidBodyCinfo boxInfo;

	boxInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
	boxInfo.m_mass = massProperties.m_mass;
	boxInfo.m_shape = shape;
	//boxInfo.m_shape = boxShape;
	boxInfo.m_qualityType = HK_COLLIDABLE_QUALITY_CRITICAL;
	boxInfo.m_motionType = hkpMotion::MOTION_BOX_INERTIA;


	boxInfo.m_position.set(0.0f, 30.0f, -2.0f);


	// Create RigidBody
	hkpRigidBody* RigidBody = new hkpRigidBody(boxInfo);
	shape->removeReference();

	physicsWorld->addEntity(RigidBody);

    g_ball = RigidBody;

	RigidBody->removeReference();

 

Also I have another test project that creates a vehicle chassis with the same method, and the floor like this:

 

	// Create the floor as a fixed box
	{
		hkpRigidBodyCinfo boxInfo;
		hkVector4 boxSize(50.0f, 2.5f , 50.0f);
		hkpBoxShape* boxShape = new hkpBoxShape(boxSize);
		boxInfo.m_shape = boxShape;
		boxInfo.m_motionType = hkpMotion::MOTION_FIXED;
		boxInfo.m_position.set(0.0f, 0.0f, 0.0f);
		boxInfo.m_restitution = 0.9f;

		hkpRigidBody* floor = new hkpRigidBody(boxInfo);
		boxShape->removeReference();

		physicsWorld->addEntity(floor);
		floor->removeReference();
	}

 

The behaviour is again quite strange. Download this Visual Debugger movie file test.hkm to see.

If I create just a normal hkpBoxShape instead of hkpSimpleMeshShape, it settles on the ground nicely.

Sorry this was a lot of text, but hopefully you could provide some assistance.

Best Regards,

vfgdfg

sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
October 13, 2008 7:52 PM PDT
Rate
 
#1

Hi vfgdfg,

This is a pretty cool post with the gifs and everything.

Just a few observations which might help you get past this.The hkpSimpleMeshShape is kind of on the outs. The hkpExtendedMeshShape is a better solution, but if you are doing convex shapes then the hkpConvexVerticesShape. The hkpBoxShape would be best, as you have mentioned.

We have seen a few things with the hkpSimpleMeshShape and welding. You can try turning this off and seeing if that gets you anywhere.

It is also not a great idea to have moving MOPPs. You are going to want to use a MOPP for your static geometry.

Give those a try and see if that gets it working. We'll go from there if you are still experiencing problems.

Thanks,
Sean



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
October 14, 2008 1:36 PM PDT
Rate
 
#2 Reply to #1

Hi,

thanks for the response. I commented out the welding code from both shapes and it fixed it! The box still does drop off though, but it does it quite naturally and because of the -2 Z-position of the box :)

If I set the Z to zero, it settles on the other box nicely after some sliding.

I actually copy pasted the welding code from this forum, hoping it would the missing piece to my original problem, which was when the boxes came to contact, the whole application crashed. But upgrading to Havok 6 fixed that, leaving only the bizzarre behaviour problem, which is now fixed, thanks.

The vehicle test acts still all weird after commenting the welding code, but I'll have to do further testing tomorrow and try that hkpExtendedMeshShape you suggested. I'll get back to you with the results.

Thanks a lot for the help.

Best Regards,

vfgdfg



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
October 16, 2008 11:51 AM PDT
Rate
 
#3 Reply to #2

Hi,

I have now replaced the other shape in my code to hkpExtendedMeshShape. I'm creating just one test triangle to it for now. But something's wrong, it now crashes to physicsWorld->addEntity(g_floor);

		hkpExtendedMeshShape* shape2 = new hkpExtendedMeshShape();

		hkpExtendedMeshShape::TrianglesSubpart part;
		
		float verts[9];
		verts[0]=0; verts[1]=1; verts[2]=2;
		verts[3]=3; verts[4]=4; verts[5]=5;
		verts[6]=6; verts[7]=7; verts[8]=8;

		part.m_vertexBase = verts;
		part.m_vertexStriding = sizeof(float)*3;
		part.m_numVertices = 3;

		unsigned short faces[3];
		faces[0]=0; faces[1]=3; faces[2]=6;

		part.m_indexBase = faces;
		part.m_indexStriding = sizeof( unsigned short)*3;
		part.m_numTriangleShapes = 1;

		part.m_stridingType = hkpExtendedMeshShape::INDICES_INT16;

		shape2->addTrianglesSubpart( part );

		boxInfo.m_shape = shape2;
		boxInfo.m_motionType = hkpMotion::MOTION_FIXED;
		boxInfo.m_position.set(0.0f, 0.0f, 0.0f);
		boxInfo.m_restitution = 0.9f;

		g_floor = new hkpRigidBody(boxInfo);
		shape2->removeReference();

		physicsWorld->addEntity(g_floor);

 

Would you have any ideas what could be wrong?

Best Regards,

vfgdfg



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
October 17, 2008 11:35 AM PDT
Rate
 
#4 Reply to #3

Hey vfgdfg,

Are you running in debug or release? Which version of Havok are you running? Are you getting an assert or a crash? What is the callstack for this crash/assert? There is a lot of debug code in Havok that will throw asserts which are designed to help you when you might be doing something wrong or unsafe. I tried that code out real quick and I didn't get either. Maybe I reproed it incorrectly.

Thanks,
Sean



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
October 17, 2008 3:32 PM PDT
Rate
 
#5 Reply to #4

Hi,

to be honest I'm not good at debugging C++, most of the time I run outside the debugger and output text to my log file for debugging purposes. Having said that, the Havok version is hk600r1, I am on debug mode (tried quickly to switch to release and changed the libs but got some linking errors, didn't start fighting with that any further yet). I think it's a crash but not really sure, not very familiar with asserts. Here's a shot of the state I'm thrown into when it breaks:

Best Regards,

vfgdfg



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
October 20, 2008 11:31 AM PDT
Rate
 
#6 Reply to #5

Hi vfgdfg,

Is the physicsWorld->addEntity(g_floor) the last line of your method? I am not liking those memory frees and I am not sure why they are being called before the Havok methods. Is it possible for you to post the entire callstack so I can see the whole progression. You should be able to copy and paste the callstack from Visual Studio to a text editor.

This looks like a crash and not an assert, asserts write out to the ouput window if you take a look there.

Thanks,
Sean



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
October 22, 2008 8:50 AM PDT
Rate
 
#7 Reply to #6

Hi,

there's this line:

g_floor->removeReference();

below the physicsWorld->addEntity(g_floor), but the g_floor->removeReference() is the one it seems to crash to, if I have debug outputs to the log before each call, this call is the last it outputs before. Yes I have more code after this but the bit I posted is in it's own { } block. Well actually the code continues exactly from row 50 in the code I posted above, I just replaced the hkpSimpleMeshShape creation with this piece of code.

Here comes the whole stack:

 

 	Test.exe!hkEntityAabbUtil::entityBatchRecalcAabb(const hkpCollisionInput * collisionInput=0x00fa8e80, hkpEntity * const * entityBatch=0x0012f368, int numEntities=1)  Line 125 + 0xa3 bytes	C++
 	ntdll.dll!7c9268ad() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]	
 	ntdll.dll!7c9268ad() 	
 	Test.exe!hkp3AxisSweep::addObject(hkpBroadPhaseHandle * object=, const hkAabbUint32 & aabbIn=, hkArray<hkpBroadPhaseHandlePair> & newPairs=)  Line 1556 + 0x11 bytes	C++
 	ntdll.dll!7c90e5e5() 	
 	ntdll.dll!7c90e9ff() 	
 	kernel32.dll!7c810e16() 	
 	kernel32.dll!7c810e36() 	
 	kernel32.dll!7c810e36() 	
>	Test.exe!_write_nolock(int fh=7469004, const void * buf=0x00fa0000, unsigned int cnt=0)  Line 301 + 0x3c bytes	C
 	ntdll.dll!7c91056d() 	
 	Test.exe!_CrtIsValidHeapPointer(const void * pUserData=0x0071a904)  Line 1963	C++
 	Test.exe!_free_dbg_nolock(void * pUserData=0x00000004, int nBlockUse=7360125)  Line 1329 + 0x9 bytes	C++
 	Test.exe!_free_dbg(void * pUserData=0x00fa3818, int nBlockUse=1)  Line 1199 + 0x7 bytes	C++
 	Test.exe!_Mtxunlock(_RTL_CRITICAL_SECTION * _Mtx=0x00fa3818)  Line 54	C
 	Test.exe!free(void * pUserData=0x00fa3818)  Line 1152 + 0xb bytes	C++
 	Test.exe!std::_DebugHeapDelete<std::locale>()  + 0x16 bytes	C++
 	Test.exe!std::ios_base::_Ios_base_dtor(std::ios_base * _This=0x0012f7b4)  Line 58 + 0xc bytes	C++
 	Test.exe!cprint()  + 0xc9 bytes	C++
 	ntdll.dll!7c96e0d4() 	
 	ntdll.dll!7c926abe() 	
 	ntdll.dll!7c926abe() 	
 	ntdll.dll!7c926abe() 	
 	ntdll.dll!7c9268ad() 	
 	ntdll.dll!7c926abe() 	
 	ntdll.dll!7c9268ad() 	
 	wl_hook.dll!1000a548() 	
 	wl_hook.dll!1000a35f() 	
 	wl_hook.dll!10009d4d() 	
 	wl_hook.dll!10009f4d() 	
 	wl_hook.dll!10009f23() 	
 	wl_hook.dll!10009f01() 	
 	wl_hook.dll!10009a1b() 	
 	wl_hook.dll!10009868() 	
 	wl_hook.dll!1000727a() 	
 	wl_hook.dll!10020d26() 	
 	ntdll.dll!7c90e03c() 	
 	kernel32.dll!7c8213c0() 	
 	dinput8d.dll!6d31c636() 	
 	dinput8d.dll!6d31c6cf() 	
 	dinput8d.dll!6d31c6dd() 	
 	dinput8d.dll!6d315c86() 	
 	Test.exe!_openfile(const char * filename=0x00000078, const char * mode=0x003c5948, int shflag=3932160, _iobuf * str=0x7c926abe)  Line 221 + 0x6d bytes	C
 	ntdll.dll!7c96e0d4() 	
 	ntdll.dll!7c96e0d4() 	
 	ntdll.dll!7c94a5d0() 	
 	ntdll.dll!7c926abe() 	
 	kernel32.dll!7c809e80() 	
 	kernel32.dll!7c80bcfe() 	
 	dinput8d.dll!6d332b5f() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30aa94() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30aa94() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30a9a0() 	
 	ntdll.dll!7c90fb6c() 	
 	ntdll.dll!7c90fb71() 	
 	ntdll.dll!7c90e20a() 	
 	kernel32.dll!7c80261a() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30aa94() 	
 	dinput8d.dll!6d335ced() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30aa94() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30aa94() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30aa94() 	
 	ntdll.dll!7c90d592() 	
 	advapi32.dll!77dd6bcc() 	
 	dinput8d.dll!6d30a9a0() 	
 	dinput8d.dll!6d30aa94() 	
 	dinput8d.dll!6d30c2c4() 	
 	dinput8d.dll!6d30c2e5() 	
 	dinput8d.dll!6d30f6e7() 	
 	dinput8d.dll!6d30e48e() 	
 	dinput8d.dll!6d30f713() 	
 	Test.exe!InitKeyb()  + 0xab bytes	C++
 	Test.exe!hkMatrix6::sub()  + 0x10061c bytes	C++
 	Test.exe!_WinMain@16()  + 0x13c bytes	C++
 	Test.exe!__tmainCRTStartup()  Line 315 + 0x35 bytes	C
 	Test.exe!WinMainCRTStartup()  Line 187	C
 	kernel32.dll!7c816ff7() 	

 

 

Best Regards,

vfgdfg



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
October 23, 2008 4:59 PM PDT
Rate
 
#8 Reply to #7

Hi vfgdfg,

I'm not quite sure what is causing this crash. My suggestion is to take this code out of your program and put it into the demo framework. It should be pretty easy to do that. Then, see if it still crashes. I haven't been able to reproduce the crash you are seeing. If you can get the crash in the demo framework, let me know the details.

Thanks for posting the call stack. Sorry I can't be more helpful at this time.

-Sean



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
October 24, 2008 4:41 PM PDT
Rate
 
#9 Reply to #8

Hi,

I replaced the vehicle hull creation code in the vehicleapi demo and got kind of similiar result (entityBatchRecalcAabb):

 	Demos_win32-net_8-0_debug_multithreaded.exe!hkEntityAabbUtil::entityBatchRecalcAabb(const hkpCollisionInput * collisionInput=0x016739e0, hkpEntity * const * entityBatch=0x016747b4, int numEntities=1)  Line 82 + 0x76 bytes	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkpMotion::getNumInactiveFramesMt(int select=0, int worldDeactivationNumInactiveFramesSelectFlag=1065353216)  Line 188 + 0x19 bytes	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkpMotion::zeroNumInactiveFramesMt(int select=1030071700, int worldDeactivationNumInactiveFramesSelectFlag=1065353216)  Line 215 + 0xe bytes	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkRigidMotionUtilApplyForcesAndStep(const hkpSolverInfo & solverInfo={...}, const hkStepInfo & info={...}, const hkVector4 & deltaVel={...}, hkpMotion * const * motions=0x00000000, int numMotions=0, int motionOffset=0)  Line 271 + 0x11 bytes	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkMultiThreadCheck::accessCheck(hkMultiThreadCheck::AccessType type=48)  Line 188 + 0xf bytes	C++
 	d3d9.dll!4fe758f4() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for d3d9.dll]	
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkJobQueue::addJob(hkJob & job=, hkJobQueue::JobPriority priority=)  Line 714	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkJobQueue::addJob(hkJob & job=, hkJobQueue::JobPriority priority=)  Line 714 + 0xf bytes	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkpMultiThreadedSimulation::processNextJob(hkJobQueue & jobQueue={...}, hkJobQueue::JobQueueEntry & job={...})  Line 126 + 0xb bytes	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkJobQueue::processAllJobs()  Line 434	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkpWorld::stepMultithreaded(hkJobQueue * jobQueue=0x028d7910, hkJobThreadPool * threadPool=0x028d7b20, float physicsDeltaTime=0.016000001)  Line 2358	C++
>	Demos_win32-net_8-0_debug_multithreaded.exe!hkDefaultPhysicsDemo::stepDemo()  Line 372	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!VehicleApiDemo::stepDemo()  Line 209	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!MenuDemo::stepCurrentDemo()  Line 1118 + 0x14 bytes	C++
 	d3d9.dll!4fe09994() 	
 	d3d9.dll!4fe6560f() 	
 	d3d9.dll!4fe6561d() 	
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkgDisplayContextDX9S::setBlendState(bool on=true)  Line 152	C++
 	d3d9.dll!4fe10780() 	
 	d3d9.dll!4fe10f79() 	
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkgDisplayContext::unlock()  Line 455	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!render(hkgWindow * window=0x00000000, const hkDemoEnvironment & env={...}, hkDemo * demo=)  Line 878	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!render()  Line 878 + 0x10 bytes	C++
 	d3d9.dll!4fe51c64() 	
 	d3d9.dll!4fe55836() 	
 	d3d9.dll!4fdf5e25() 	
 	d3d9.dll!4fe55845() 	
 	d3d9.dll!4fe78933() 	
 	d3d9.dll!4fe5714f() 	
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkgWindowDX9SPC::clearBuffers()  Line 659	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkgDisplayContext::unlock()  Line 455	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!hkFrameworkMain(hkDemoFrameworkOptions & options={...}, char * startUpDemo=0x00da7b10)  Line 1333	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!main(int argc=1, char * * argvIn=0x01663b08)  Line 35 + 0xf bytes	C++
 	Demos_win32-net_8-0_debug_multithreaded.exe!__tmainCRTStartup()  Line 318 + 0x19 bytes	C
 	Demos_win32-net_8-0_debug_multithreaded.exe!mainCRTStartup()  Line 187	C
 	kernel32.dll!7c816ff7() 	

You can download the new VehicleApiDemo.cpp here

Best regards,

vfgdfg



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
October 28, 2008 7:22 PM PDT
Rate
 
#11 Reply to #9

Hi vfgdfg,

My advice is not to use a single triangle for you vehicle. Try using a convex vertices shape. I was experiencing problems with calculating the inertia tensor using your code. Did you not hit that problem? ExtendedMeshShapes are really good for fixed terrain. You are probably going to experience slow downs if you use it for dynamic collisions as a collision agent will be created for each triangle.

Thanks,
Sean



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
October 29, 2008 4:20 PM PDT
Rate
 
#12 Reply to #11

Hi,

I used only one triangle to just make it work, as simple as possible. I only got the error I posted above.

But ok I can try going with hkpConvexVerticesShape, but how can I create one based on my existing mesh triangle data?

Best Regards,

vfgdfg



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
October 31, 2008 5:44 PM PDT
Rate
 
#13 Reply to #12

Hi vfgdfg,

You can take a look at the docs on this. There is a section in Havok Physics->Collision Detection->Creating Shapes. There is a section in there on Convex Vertices shapes. One note on using hkpGeometryUtility::createConvexGeometry(). You might need to perturb the vertices by a tiny amount to get good convex geometry.

There is also the option of providing a convex geometry from the modeller. If you have a car for example, you could just use a box if you wanted. Then have a more detailed render geometry. You'd probably want to use a better shape then a box, but that's the basic idea.

Hope this helps,

Sean



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
November 9, 2008 10:32 AM PST
Rate
 
#14 Reply to #13

Hey again,

sorry to keep bothering you with this, but going back to the hkpExtendedMeshShape once more, since I understand I'll be better of using that for map geometry, I gave it another shot today, I put my code to the standalone console demo and I still get the crash at hkEntityAabbUtil::entityBatchRecalcAabb(const hkpCollisionInput, but in the console I got intresting message:

----------------------------
Havok - Build (20080925)
Version 6.0.0 (r1)
Base system initialized.
----------------------------
e:\RSYS\Build\code\PcXsPerpetualKeycode\Source\Common/Base/Math/Vector/hkVector4
Util.inl(122): [0x4868F301] Assert : aabb.isValid()
Aabb at 0012E980 was invalid. (Contains a NaN or min > max)

But still not sure where the problem is. But, I found some another example code (on this forum again, but it's pretty similiar to the TowerLand.cpp which btw I couldn't find in the actual example program) that uses hkArray for the buffers and that way my test code doesn't crash, but I don't get anything on the Visual Debugger either except for the moving ball (I've disabled the brickwalls and floor creation).

There's some ".\World\BroadPhaseBorder\hkpBroadPhaseBorder.cpp(131): [0x65567363] Warning : En
tity left the broadphase and has been removed from the hkpWorld. See hkpWorldCin
fo::BroadPhaseBorderBehaviour for details." text in the Console for three times, probably has to do with it since it doesn't give them if I don't create the shape, but I can't figure out what the problem is.

I zipped the project here, if you would have the time to take a look at it, it's small (just the cpp and some solution files) and it should work just extracting under demo\StandAloneDemos. There's a new addExtendedTestBox method that has three different pieces of test code, first one the code I found which doesn't work and it's commented out, then the test code I made based on it and which doesn't crash but nothing appears in the Visual Debugger, and lastly the "original" code, which now creates a full box though instead of one triangle, it's commented out as well.

Basicly I  would just need some code to set up a hkpExtendMeshShape with some given triangle data to get going with it.

Thanks for your time,

Jarno

ps. I haven't tried the Convex Shape yet but I will.



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
November 11, 2008 11:40 AM PST
Rate
 
#15 Reply to #14

Hi Jarno,

I've taken a look at your demo. Thanks for providing it (that makes my life much easier). I've noticed a few problem with the way you set up the triangles.

In the middle sample of code, the one using the hkArray, you specify that there are 32 triangles and 24 vertices. That is a problem because while there are 24 numbers in your vertices array, there are only 8 actual vertices (24 values - 3 values per vertex). There are also only 12 faces. You have this correct in the last sample of code. This is probably just a little oversight.

In both the middle and last samples of code you may have set up the faces incorrectly. You have faces[14]=18; for example. The faces array should give an unstrided value, so  your 18 should be 6. This is a pretty easy mistake to make, sorry I didn't catch it sooner. Since there are only 8 vertices in your example, you are indexing out the vertices array. This will cause all kinds of unpredicatable behavior. The face vertices were getting set to like MAX kind of values, which causes the AABB generation to create NANs. I think that if you get the vertices all mapped out right, everything will fall in place.

The warning about leaving the broadphase happens in the stand alone demo becuase the moving ball eventually moves out of the broadphase. You shouldn't need to worry about that one.

Sorry it took a little while for me to get back on this one. It had me a little confused for a while there.

Let me know if that fixes the problem.

Thanks,
Sean

 



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
November 12, 2008 9:07 AM PST
Rate
 
#16 Reply to #15

Hi,

shamefully I have to admit I don't know what strided/unstrided means. But I put the values in to a graphical presentation and the only problem I saw was that some faces were facing the wrong direction (I don't think Havok should care?) and  faces[22]=23 should have been faces[22]=21;

But anyway I now put in different data from a properly formed cube and set numVertices to 8 and numTriangleShapes to 12. The output is exactly the same, no error, but nothing shown in the Visual Debugger. Even the original 32 triangles and 24 vertices do not produce an error.
With the original code I actually did get 3 times the "leaving the broadphase" warning just after starting the program, BEFORE the ball leaving the area. But with the new code that doesn't happen so never mind that.

Anyway I put the same new cube data for the second test as well and the result is same than before, crash at AABB generation. This code does have the correct number of vertices and faces already as you said.

I've uploaded the updated project here. I disposed the first piece of example code and separated the two other codes to addExtendedTestBox1 and addExtendedTestBox2 methods to make it a bit less a mess.

I also added hkpSimpleMeshShape test (addSimpleTestBox) with the same cube data and that actually works just fine, nice big box appears in the visual debugger!

But by default the addExtendedTestBox1 is now called and it's the one that doesn't produce any error. To try the other ones, just change the comments before the calling of the methods.

Best Regards,

Jarno



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
November 12, 2008 11:48 AM PST
Rate
 
#17 Reply to #16

Hi Jarno,

You are really close on this one. What I mean by unstrided is that you give the vertex number instead of where it starts in the vertex array. So where you have something like 1*3, you would just have 1. That is which vertex it is. I have changed your face code below and now I see a cube without any asserts. I was seeing asserts with all 3. Indexing out of the array can be unpredictable which is why you might not have seen any asserts.

// front
	faces[0]=0; faces[1]=1; faces[2]=2;
	faces[3]=1; faces[4]=3; faces[5]=2;

	// right
	faces[6]=2; faces[7]=3; faces[8]=6;
	faces[9]=3; faces[10]=7; faces[11]=6;

	// back
	faces[12]=6; faces[13]=7; faces[14]=4;
	faces[15]=7; faces[16]=5; faces[17]=4;

	// left
	faces[18]=4; faces[19]=5; faces[20]=0;
	faces[21]=5; faces[22]=1; faces[23]=0;

	// top
	faces[24]=1; faces[25]=5; faces[26]=3;
	faces[27]=5; faces[28]=7; faces[29]=3;

	// bottom
	faces[30]=2; faces[31]=6; faces[32]=0;
	faces[33]=6; faces[34]=4; faces[35]=0;

Give this a try and let me know if you are seeing a cube.

Thanks,
Sean



vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
November 13, 2008 1:23 AM PST
Rate
 
#18 Reply to #17
Hey,
now I see what you mean, thanks. I tried it and this is what I see:
Yes, a face, but it's definetly an improvement. This is from addExtendedTestBox1, addExtendedTestBox2 crashes to
ConsoleExampleMt_win32-net_8-0_debug_multithreaded.exe!hkpExtendedMeshShape::getChildShape(unsigned int key=0, char [512]& buffer=0x001263b0)  Line 503 C++

I'll look more in to it tonight. Is this the only change you did? Did you get the box from both methods?
Thanks,
Jarno


vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
November 16, 2008 4:20 AM PST
Rate
 
#19 Reply to #18
Uh I just don't get it at all now. The triangle is not actually a part of a proper cube, it's aligned wrong. It's coming from this line:
faces[9]=3; faces[10]=7; faces[11]=6;
But, changing the position values of vertice 3 does not affect the shape of the triangle at all (the other two does). Just to make sure I changed all the other vertices as well, no difference. And talk about all the other missing triangles:O I also did another test where I had just one triangle with this working triangle's data and didn't see anything. Something's definetly wrong, I don't understand it. Either my environment must be messed up (I tried the same project in my laptop and the result was the same though) or could there be some bug with TryHavok (I assume you tried with the full version)?

Sorry for being such a pain, but I just really would need to get this working because my game has it's own map editor and so I need to be able to generate the map data from it.

Best Regards,

Jarno


sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
November 17, 2008 3:09 PM PST
Rate
 
#20 Reply to #19

Hi Jarno,

I had done this in the demo framework and I saw a cube being rendered. I didn't check the VDB.  Now that I check with the VDB, I do a strange triangles. I need to look into this further.

I will post again when I have more info.

Thanks,
Sean



sean.thurston
Total Points:
8,322
Status Points:
0
Brown Belt
November 24, 2008 11:36 AM PST
Rate
 
#21 Reply to #20
Hi Jarno,
It looks like you have got this working (from the other post). I see now that the problem was that you were declaring the vertex and face information locally. It was being lost when the function finished. By storing the information as a member variable of the class it should work. Sorry I missed this.
Thanks,
Sean


vfgdfg
Total Points:
560
Status Points:
60
Brown Belt
November 25, 2008 6:37 AM PST
Rate
 
#22 Reply to #21

Hi,

yes I got the piece of code in the other thread working but it still wasn't exactly what I was looking for here. However now that I changed the vertex and face array declarations to global I got the 2nd test working and finally see a box!!:D Also a more complex mesh works with it! Thanks a ton! Finally I can start proceeding with integration work. But I'm pretty sure this isn't the last you'll hear from me:)

Thanks a lot,

Jarno





Intel Software Network Forums Statistics

8442 users have contributed to 31549 threads and 100378 posts to date.
In the past 24 hours, we have 11 new thread(s) 34 new posts(s), and 47 new user(s).

In the past 3 days, the most popular thread for everyone has been /fpp interferes with breakpoints/stepping through code - again The most posts were made to Help with hitting maximum record length in the compiler with debug info? The post with the most views is You could save the pre-proce

Please welcome our newest member mrnm