Quantcast
Channel: Intel® Developer Zone - Havok
Viewing all 168 articles
Browse latest View live

Havok time step has been decreased by more than a factor of 4.0000 warning

$
0
0

I've added havok into my game and i run my game and it lags like crazy and the warning:

havok time step has been decreased by more than a factor of 4.0000 shows up everytime I step havok.


Simulation problem with too many boxes.

$
0
0

Hi

When i create too many boxes my project raise error while simulating Havok scene.

Here is my create box script:

			markForWrite();
			const hkVector4 boxSize(mWidth, mHeight, mDepth);
			hkpBoxShape* boxShape = new hkpBoxShape( boxSize , 0 );
			hkVector4 boxPosition(mPos.x,mPos.y,mPos.z);
			hkpRigidBodyCinfo info;
			{
			    info.m_motionType = hkpMotion::MOTION_DYNAMIC;
			    setNeedSimulate(true);
			    addFlag(AT_CONSTANTS_PHYSIC_OBJECTFLAG_DYNAMIC);
				info.m_friction = 0.5;
				info.m_shape = boxShape;
				info.m_position = boxPosition;
			}
			mActor= new hkpRigidBody(info);
			boxShape->removeReference();
			mScene->addEntity(mActor);
			mActor->requestDeactivation();
			mActor->setRotation(mPos);
			unmarkForWrite();

Here is my simulate script:

    if (deltatime>0)
    {
	    mWorld->stepMultithreaded( mJobQueue, mThreadPool, deltatime);
	    // Step the visual debugger. We first synchronize the timer data
	    mContext->syncTimers( mThreadPool );
	    mVisualDebugger->step();

	    // Clear accumulated timer data in this thread and all slave threads
	    hkMonitorStream::getInstance().reset();
	    mThreadPool->clearTimerData();
    }

Here is my Havok initialization script:

		mMemoryRouter = hkMemoryInitUtil::initDefault( hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo( 100* 1024* 1024 ) );
		hkBaseSystem::init(mMemoryRouter, errorReport );
		{
			// Initialize the multi-threading classes, hkJobQueue, and hkJobThreadPool
			hkJobThreadPool* threadPool;

			// We can cap the number of threads used - here we use the maximum for whatever multithreaded platform we are running on. This variable is
			// set in the following code sections.
			int totalNumThreadsUsed;

			// Get the number of physical threads available on the system
			hkHardwareInfo hwInfo;
			hkGetHardwareInfo(hwInfo);
			totalNumThreadsUsed = hwInfo.m_numThreads;

			// We use one less than this for our thread pool, because we must also use this thread for our simulation
			hkCpuJobThreadPoolCinfo threadPoolCinfo;
			threadPoolCinfo.m_numThreads = totalNumThreadsUsed - 1;

			// This line enables timers collection, by allocating 200 Kb per thread.  If you leave this at its default (0),
			// timer collection will not be enabled.
			threadPoolCinfo.m_timerBufferPerThreadAllocation = 200000;
			threadPool = new hkCpuJobThreadPool( threadPoolCinfo );

			// We also need to create a Job queue. This job queue will be used by all Havok modules to run multithreaded work.
			// Here we only use it for physics.
			hkJobQueueCinfo info;
			info.m_jobQueueHwSetup.m_numCpuThreads = totalNumThreadsUsed;
			hkJobQueue* jobQueue = new hkJobQueue(info);

			// Enable monitors for this thread.
			// Monitors have been enabled for thread pool threads already (see above comment).
			hkMonitorStream::getInstance().resize(200000);

			// <PHYSICS-ONLY>: Create the physics world.
			// At this point you would initialize any other Havok modules you are using.
			hkpWorld* physicsWorld;
			{
				// The world cinfo contains global simulation parameters, including gravity, solver settings etc.
				hkpWorldCinfo worldInfo;
				worldInfo.m_collisionTolerance = 0.1f;
				worldInfo.m_contactPointGeneration = hkpWorldCinfo::CONTACT_POINT_ACCEPT_ALWAYS;
				worldInfo.setBroadPhaseWorldSize(12000);

				// Set the simulation type of the world to multi-threaded.
				worldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_MULTITHREADED;

				// Flag objects that fall "out of the world" to be automatically removed - just necessary for this physics scene
				worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;//hkpWorldCinfo::BROADPHASE_BORDER_REMOVE_ENTITY;

				physicsWorld = new hkpWorld(worldInfo);

				// Disable deactivation, so that you can view timers in the VDB. This should not be done in your game.
				physicsWorld->m_wantDeactivation = false;


				// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
				// to make sure only one thread is modifying the world at once to prevent multithreaded bugs. Each thread
				// must call markForRead / markForWrite before it modifies the world to enable these checks.
				physicsWorld->markForWrite();


				// Register all collision agents, even though only box - box will be used in this particular example.
				// It's important to register collision agents before adding any entities to the world.
				hkpAgentRegisterUtil::registerAllAgents( physicsWorld->getCollisionDispatcher() );

				// We need to register all modules we will be running multi-threaded with the job queue
				physicsWorld->registerWithJobQueue( jobQueue );
			}

			// Initialize the VDB
			hkArray<hkProcessContext*> contexts;


			// <PHYSICS-ONLY>: Register physics specific visual debugger processes
			// By default the VDB will show debug points and lines, however some products such as physics and cloth have additional viewers
			// that can show geometries etc and can be enabled and disabled by the VDB app.
			hkpPhysicsContext* context;
			{
				// The visual debugger so we can connect remotely to the simulation
				// The context must exist beyond the use of the VDB instance, and you can make
				// whatever contexts you like for your own viewer types.
				context = new hkpPhysicsContext();
				hkpPhysicsContext::registerAllPhysicsProcesses(); // all the physics viewers
				context->addWorld(physicsWorld); // add the physics world so the viewers can see it
				contexts.pushBack(context);

				// Now we have finished modifying the world, release our write marker.
				physicsWorld->unmarkForWrite();
			}

			hkVisualDebugger* vdb = new hkVisualDebugger(contexts);
			vdb->serve();

			// Set the local pointers
			mVisualDebugger = vdb;
			mWorld = physicsWorld;
			mJobQueue = jobQueue;
			mThreadPool = threadPool;
			mContext = context;
		}
		mInitialized = true;

 

Notes:

1.Havok don't say any thing about the error and i have no assert or error or even warning in my log. even with debugging in VS2012 i didn't success to found useful things exists in callstack.

2.The error exists also in single thread simulation, and exactly throw after creating more than 16384 boxes.

3.Increasing sizeof memory router don't help.

 

My call stack on error time(When i create one box after one):

>	00000000()	Unknown
 	[Frames below may be incorrect and/or missing]
 	project.exe!hkBoxBoxAgent3::cleanup(hkpAgentEntry * entry, void * agentData, hkpContactMgr * mgr, hkpConstraintOwner & constraintOwner) Line 91	C++
 	project.exe!hkBoxBoxAgent3::destroy(hkpAgentEntry * entry, void * agentData, hkpContactMgr * mgr, hkpConstraintOwner & constraintOwner, hkpCollisionDispatcher * dispatcher) Line 138	C++
 	project.exe!hkAgentNnMachine_DestroyAgent(hkpAgentNnTrack & track, hkpAgentNnEntry * entry, hkpCollisionDispatcher * dispatcher, hkpConstraintOwner & constraintOwner) Line 344	C++
 	project.exe!hkpWorldAgentUtil::removeAgent(hkpAgentNnEntry * agent) Line 180	C++
 	project.exe!hkpMultiThreadedSimulation::MtEntityEntityBroadPhaseListener::removeCollisionPair(hkpTypedBroadPhaseHandlePair & pair) Line 357	C++
 	project.exe!hkpTypedBroadPhaseDispatcher::removePairs(hkpTypedBroadPhaseHandlePair * deletedPairs, int numDeletedPairs) Line 65	C++
 	project.exe!hkpSingleThreadedJobsOnIsland::cpuBroadPhaseJob(hkpMtThreadStructure & tl, hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & nextJobOut) Line 206	C++
 	project.exe!hkpMultiThreadedSimulation::processNextJob(hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & job) Line 198	C++
 	project.exe!hkJobQueue::processAllJobs(bool addTimers) Line 559	C++
 	project.exe!hkCpuJobThreadPool::workerFunction(void * workLoad) Line 76	C++
 	project.exe!hkCpuThreadPool::threadMain(void * v) Line 144	C++

 

My call stack on error time(When i create all boxes and then start simulation):

>	project.exe!hkAgentNnMachine_DestroyAgent(hkpAgentNnTrack & track, hkpAgentNnEntry * entry, hkpCollisionDispatcher * dispatcher, hkpConstraintOwner & constraintOwner) Line 367	C++
 	project.exe!hkpWorldAgentUtil::removeAgent(hkpAgentNnEntry * agent) Line 180	C++
 	project.exe!hkpMultiThreadedSimulation::MtEntityEntityBroadPhaseListener::removeCollisionPair(hkpTypedBroadPhaseHandlePair & pair) Line 357	C++
 	project.exe!hkpTypedBroadPhaseDispatcher::removePairs(hkpTypedBroadPhaseHandlePair * deletedPairs, int numDeletedPairs) Line 65	C++
 	project.exe!hkpSingleThreadedJobsOnIsland::cpuBroadPhaseJob(hkpMtThreadStructure & tl, hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & nextJobOut) Line 206	C++
 	project.exe!hkpMultiThreadedSimulation::processNextJob(hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & job) Line 198	C++
 	project.exe!hkJobQueue::processAllJobs(bool addTimers) Line 559	C++
 	project.exe!hkCpuJobThreadPool::workerFunction(void * workLoad) Line 76	C++
 	project.exe!hkCpuThreadPool::threadMain(void * v) Line 144	C++
 	ntdll.dll!77a59f72()	Unknown
 	[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
 	ntdll.dll!77a59f45()	Unknown

 

Thank you for any help.

H.Ahmadi

How much is the HavokDestruction?

$
0
0

hello everybody:

          I want to buy the Havok Destruction,but I don't know how much is it?Is there Anybody can tell me the price? thank you!

                                                                                                                                                                                          Wang

Automatically deactivation on box stack

$
0
0

Hi

I have some boxes (consider them as a wall or a stack) , They have stress and never deactivate automatically!

I can manually force them to deactivate or even run requestDeactivate() for all of them but surely Havok engine have internally configuration for automatically deactivation, I just have following option in my init():

physicsWorld->m_wantDeactivation = true;

Is that enough?

You can see full of my test-case source in https://software.intel.com/en-us/forums/topic/517625

Thank you in advance

H.Ahmadi

 

 

shape castray

$
0
0

hello, I test shape cast ray,the code:


//r_box1 is a box rigidbody.


hkpShapeRayCastInput in_ray;


in_ray.m_from.set(500,500,500);
in_ray.m_to.set(50,0,50);
 
hkpShapeRayCastOutput out_ray;
if(r_box1->getCollidable()->getShape()->castRay(in_ray,out_ray))
{
        hkVector4 intersectionPointWorld;
        intersectionPointWorld.setInterpolate4( in_ray.m_from, in_ray.m_to, out_ray.m_hitFraction );
        HK_DISPLAY_LINE(in_ray.m_from, intersectionPointWorld, hkColor::RED);
        HK_DISPLAY_ARROW(intersectionPointWorld, out_ray.m_normal, hkColor::CYAN); }
else
{
       HK_DISPLAY_LINE(in_ray.m_from, in_ray.m_to, hkColor::rgbFromChars(200, 200, 200));
// Otherwise draw as GREY
}


but soon in VDB, I  find the Grey line cross the box !  the line is not change to red,where is wrong in code?

I can't load a correct .htx model into the havok. please check out the description.

$
0
0

Hello everybody:

        I have a simple problem but I can't how to solve. After I create a simple .hkx model "teapot" by 3ds max,I want to load it into my Havok. The model shows like this      

But when I load it into my Havok, the model is bacome,

like this

  I don't know where I have a mistake,so I hope someone can give me some advanced issues.Thank you!

 

Programmer/Software Engineer positions open for well established USA company

$
0
0

Applicants,

 

Phoenix Core Entertainment specializes in event horizon architectural design and implementation. The particular project that the position open will be working on is an interactive video game franchise/series with a new genre that has never been done before. We have multiple programming positions open in Minnesota and the United States of America. All applicants MUST be currently a USA citizen.

 

Must be able to keep up with an experienced team of artists, programmers, and writers. Interested applicants please send a private message to this account to recieve the contact information required to forward a resume. If you have experience using any of the Havok development toolsets, in particular the vision engine, please include that information in your resume.

 

 

Must be at least 18 years old or older.

 

Past experience working with video games preferred.



Must know LUA script.



C++ experience preferred albeit not nessary.

 

English as a FIRST language.

 

Must be comfortable working remotely.

 

All other details to be discussed via email.

Regards,

 

PCE mgmt



 

PLEASE NOTE: IF YOU ARE NOT A CURRENT CITIZEN OF THE USA PLEASE DO NOT APPLY. YOUR APPLICATION WILL NOT BE CONSIDERED AT THIS TIME. WE CANNOT SUPPLY ANY INTERNATIONAL VISA STATUS AND WILL NOT BE OFFERING SUPPOT IN VISA STATUS.

How to deactivate 2 penetrated boxes.

$
0
0

Hi

Fortunately I have been success to finish reading full of Havok documentation, Thanks for it, That was very useful !

As the Havok's Document say, When two rigid bodies have penetration(For example 2 boxes that an artist did wrong at positioning them), deactivation method can not deactivate them while they have penetration.

But i want something else, because when player reach to some part of my game map that the two boxes exists there, they must be activated.

Is it any way to deactivate the 2 boxes until the island of them be activated with some things else of penetration? (for example entering player vehicle on the island)

 

Thanks for any help.

H.Ahmadi


Vehicle wheels don't appear in VDB(Movie included)!

$
0
0

Hi

My vehicle slide and i can't control it, for debugging i'm using VDB but it don't show my wheels! (Selecting Virsual Debugger->Viewer->Vehicle menu don't do anything and just mesh shapes appear in vdebugger)

I did copy all vehicle setup codes without any change from "Havok\Demo\Demos\Physics2012\Api\Vehicle\Car\CarDemo.cpp" but only the Havok demo wheels appear in the VDB not my application. 

Also my VDB initializer  is :

			// Initialize the VDB
			hkArray<hkProcessContext*> contexts;


			// <PHYSICS-ONLY>: Register physics specific visual debugger processes
			// By default the VDB will show debug points and lines, however some products such as physics and cloth have additional viewers
			// that can show geometries etc and can be enabled and disabled by the VDB app.
			hkpPhysicsContext* context;
			{
				// The visual debugger so we can connect remotely to the simulation
				// The context must exist beyond the use of the VDB instance, and you can make
				// whatever contexts you like for your own viewer types.
				context = new hkpPhysicsContext();
				hkpPhysicsContext::registerAllPhysicsProcesses(); // all the physics viewers
				context->addWorld(physicsWorld); // add the physics world so the viewers can see it
				contexts.pushBack(context);

				// Now we have finished modifying the world, release our write marker.
				physicsWorld->unmarkForWrite();
			}
			hkVisualDebugger* vdb = new hkVisualDebugger(contexts);
			vdb->serve();

			// Set the local pointers
			mVisualDebugger = vdb;
			mContext = context;

 

Thanks for any help

H.Ahmadi

AttachmentSize
Downloadwheel_problem.zip352.99 KB

support for gyroscopic (Coriolis) forces?

$
0
0

I would like to know if Havok supports the computation of Coriolis forces.  These are velocity-dependent forces that, for example, make gyroscopes work. I found this feature in ODE (dBodySetGyroscopicMode) and Bullet [body->setFlags(BT_ENABLE_GYROPSCOPIC_FORCE)], but not in Havok.

DirectX not installed properly or older OS, so trying older renderer (DirectX9)

$
0
0

I tried to debug havok physics demos.

when there are posts appear cmd

cmd

and

but I've installed directx on my computer ..

is there anyone who can help me.

thank's

[0x638A1543] Warning: Failed to shrink the shape (Volume: 0.000000)

$
0
0

Shape\Convex\ConvexVertices\hkpConvexVerticesShapeConstructor.cpp(139): [0x638A1543] Warning: Failed to shrink the shape (Volume: 0.000000)

I'm getting this warning in my havok simulation and it's bothering me and I feel like I need it fixed so I tried to fix it myself but no luck so hopefully you guys can help.

I have a compound shape in my simulation and this is how I set it up.

hkpStaticCompoundShape* CompoundShape = new hkpStaticCompoundShape();

int vStride = 3 * sizeof(hkReal);

for(int i = 0; i < (int)m_SubMeshes.size(); i++)
{
	hkReal* Vertices = new hkReal[(int)m_SubMeshes[i].Vertices.size() * 3];
	int vc = 0;
	for(int j = 0; j < (int)m_SubMeshes[i].Vertices.size(); j++)
	{
		Vertices[vc + 0] = m_SubMeshes[i].Vertices[j].x;
		Vertices[vc + 1] = m_SubMeshes[i].Vertices[j].y;
		Vertices[vc + 2] = m_SubMeshes[i].Vertices[j].z;
		vc += 3;
	}

	hkStridedVertices stridedVerts;
	{
		stridedVerts.m_numVertices = (int)m_SubMeshes[i].Vertices.size();
		stridedVerts.m_striding = vStride;
		stridedVerts.m_vertices = Vertices;
	}

	hkpConvexVerticesShape::BuildConfig config;
	config.m_convexRadius = 0.001f;

	hkpConvexVerticesShape* VShape = new hkpConvexVerticesShape(stridedVerts, config);

	hkQsTransform trans;
	trans.setIdentity();
	trans.setTranslation(hkVector4(m_SubMeshes[i].Position.x, m_SubMeshes[i].Position.y, m_SubMeshes[i].Position.z));
	CompoundShape->addInstance(VShape, trans);
	VShape->removeReference();
	delete[] Vertices;
}

CompoundShape->bake();

hkpRigidBodyCinfo BodyInfo;
BodyInfo.m_shape = CompoundShape;
BodyInfo.m_motionType = hkpMotion::MOTION_FIXED;
BodyInfo.m_position.set(0.0f, 0.0f, 0.0f);
BodyInfo.m_restitution = 0.4f;
BodyInfo.m_friction = 0.8f;

m_pBody = new hkpRigidBody(BodyInfo);

k_pWorld->addEntity(m_pBody);
CompoundShape->removeReference();

And incase the order I do this all in matters I'll let you know how I do it.

I setup my world and visual debugger etc.

	hkMemorySystem::FrameInfo finfo(500 * 1024);
	m_pMemoryRouter = hkMemoryInitUtil::initDefault(hkMallocAllocator::m_defaultMallocAllocator, finfo);
	hkBaseSystem::init(m_pMemoryRouter, ErrorReport);

	hkpWorldCinfo worldInfo;
	worldInfo.setupSolverInfo(hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM);
	worldInfo.m_gravity = hkVector4(0.0f, -9.81f, 0.0f);
	worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;
	worldInfo.m_collisionTolerance = 0.001f;
	worldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_CONTINUOUS;
	worldInfo.m_useCompoundSpuElf = true;

	worldInfo.setBroadPhaseWorldSize(1000.0f);
	m_pWorld = new hkpWorld(worldInfo);

	hkpAgentRegisterUtil::registerAllAgents(m_pWorld->getCollisionDispatcher());

	m_pPContext = new hkpPhysicsContext;
	hkpPhysicsContext::registerAllPhysicsProcesses();
	m_pPContext->addWorld(m_pWorld);

	hkArray<hkProcessContext*> contexts;
	contexts.pushBack(m_pPContext);

	m_pVisualDebugger = new hkVisualDebugger(contexts);
	m_pVisualDebugger->serve();

Then I create my compound shape and then I step havok.

What could cause this warning and how do I fix it?

Simulation problem with too many boxes.

$
0
0

Hi

When i create too many boxes my project raise error while simulating Havok scene.

Here is my create box script:

			markForWrite();
			const hkVector4 boxSize(mWidth, mHeight, mDepth);
			hkpBoxShape* boxShape = new hkpBoxShape( boxSize , 0 );
			hkVector4 boxPosition(mPos.x,mPos.y,mPos.z);
			hkpRigidBodyCinfo info;
			{
			    info.m_motionType = hkpMotion::MOTION_DYNAMIC;
			    setNeedSimulate(true);
			    addFlag(AT_CONSTANTS_PHYSIC_OBJECTFLAG_DYNAMIC);
				info.m_friction = 0.5;
				info.m_shape = boxShape;
				info.m_position = boxPosition;
			}
			mActor= new hkpRigidBody(info);
			boxShape->removeReference();
			mScene->addEntity(mActor);
			mActor->requestDeactivation();
			mActor->setRotation(mPos);
			unmarkForWrite();

Here is my simulate script:

    if (deltatime>0)
    {
	    mWorld->stepMultithreaded( mJobQueue, mThreadPool, deltatime);
	    // Step the visual debugger. We first synchronize the timer data
	    mContext->syncTimers( mThreadPool );
	    mVisualDebugger->step();

	    // Clear accumulated timer data in this thread and all slave threads
	    hkMonitorStream::getInstance().reset();
	    mThreadPool->clearTimerData();
    }

Here is my Havok initialization script:

		mMemoryRouter = hkMemoryInitUtil::initDefault( hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo( 100* 1024* 1024 ) );
		hkBaseSystem::init(mMemoryRouter, errorReport );
		{
			// Initialize the multi-threading classes, hkJobQueue, and hkJobThreadPool
			hkJobThreadPool* threadPool;

			// We can cap the number of threads used - here we use the maximum for whatever multithreaded platform we are running on. This variable is
			// set in the following code sections.
			int totalNumThreadsUsed;

			// Get the number of physical threads available on the system
			hkHardwareInfo hwInfo;
			hkGetHardwareInfo(hwInfo);
			totalNumThreadsUsed = hwInfo.m_numThreads;

			// We use one less than this for our thread pool, because we must also use this thread for our simulation
			hkCpuJobThreadPoolCinfo threadPoolCinfo;
			threadPoolCinfo.m_numThreads = totalNumThreadsUsed - 1;

			// This line enables timers collection, by allocating 200 Kb per thread.  If you leave this at its default (0),
			// timer collection will not be enabled.
			threadPoolCinfo.m_timerBufferPerThreadAllocation = 200000;
			threadPool = new hkCpuJobThreadPool( threadPoolCinfo );

			// We also need to create a Job queue. This job queue will be used by all Havok modules to run multithreaded work.
			// Here we only use it for physics.
			hkJobQueueCinfo info;
			info.m_jobQueueHwSetup.m_numCpuThreads = totalNumThreadsUsed;
			hkJobQueue* jobQueue = new hkJobQueue(info);

			// Enable monitors for this thread.
			// Monitors have been enabled for thread pool threads already (see above comment).
			hkMonitorStream::getInstance().resize(200000);

			// <PHYSICS-ONLY>: Create the physics world.
			// At this point you would initialize any other Havok modules you are using.
			hkpWorld* physicsWorld;
			{
				// The world cinfo contains global simulation parameters, including gravity, solver settings etc.
				hkpWorldCinfo worldInfo;
				worldInfo.m_collisionTolerance = 0.1f;
				worldInfo.m_contactPointGeneration = hkpWorldCinfo::CONTACT_POINT_ACCEPT_ALWAYS;
				worldInfo.setBroadPhaseWorldSize(12000);

				// Set the simulation type of the world to multi-threaded.
				worldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_MULTITHREADED;

				// Flag objects that fall "out of the world" to be automatically removed - just necessary for this physics scene
				worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;//hkpWorldCinfo::BROADPHASE_BORDER_REMOVE_ENTITY;

				physicsWorld = new hkpWorld(worldInfo);

				// Disable deactivation, so that you can view timers in the VDB. This should not be done in your game.
				physicsWorld->m_wantDeactivation = false;


				// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
				// to make sure only one thread is modifying the world at once to prevent multithreaded bugs. Each thread
				// must call markForRead / markForWrite before it modifies the world to enable these checks.
				physicsWorld->markForWrite();


				// Register all collision agents, even though only box - box will be used in this particular example.
				// It's important to register collision agents before adding any entities to the world.
				hkpAgentRegisterUtil::registerAllAgents( physicsWorld->getCollisionDispatcher() );

				// We need to register all modules we will be running multi-threaded with the job queue
				physicsWorld->registerWithJobQueue( jobQueue );
			}

			// Initialize the VDB
			hkArray<hkProcessContext*> contexts;


			// <PHYSICS-ONLY>: Register physics specific visual debugger processes
			// By default the VDB will show debug points and lines, however some products such as physics and cloth have additional viewers
			// that can show geometries etc and can be enabled and disabled by the VDB app.
			hkpPhysicsContext* context;
			{
				// The visual debugger so we can connect remotely to the simulation
				// The context must exist beyond the use of the VDB instance, and you can make
				// whatever contexts you like for your own viewer types.
				context = new hkpPhysicsContext();
				hkpPhysicsContext::registerAllPhysicsProcesses(); // all the physics viewers
				context->addWorld(physicsWorld); // add the physics world so the viewers can see it
				contexts.pushBack(context);

				// Now we have finished modifying the world, release our write marker.
				physicsWorld->unmarkForWrite();
			}

			hkVisualDebugger* vdb = new hkVisualDebugger(contexts);
			vdb->serve();

			// Set the local pointers
			mVisualDebugger = vdb;
			mWorld = physicsWorld;
			mJobQueue = jobQueue;
			mThreadPool = threadPool;
			mContext = context;
		}
		mInitialized = true;

 

Notes:

1.Havok don't say any thing about the error and i have no assert or error or even warning in my log. even with debugging in VS2012 i didn't success to found useful things exists in callstack.

2.The error exists also in single thread simulation, and exactly throw after creating more than 16384 boxes.

3.Increasing sizeof memory router don't help.

 

My call stack on error time(When i create one box after one):

>	00000000()	Unknown
 	[Frames below may be incorrect and/or missing]
 	project.exe!hkBoxBoxAgent3::cleanup(hkpAgentEntry * entry, void * agentData, hkpContactMgr * mgr, hkpConstraintOwner & constraintOwner) Line 91	C++
 	project.exe!hkBoxBoxAgent3::destroy(hkpAgentEntry * entry, void * agentData, hkpContactMgr * mgr, hkpConstraintOwner & constraintOwner, hkpCollisionDispatcher * dispatcher) Line 138	C++
 	project.exe!hkAgentNnMachine_DestroyAgent(hkpAgentNnTrack & track, hkpAgentNnEntry * entry, hkpCollisionDispatcher * dispatcher, hkpConstraintOwner & constraintOwner) Line 344	C++
 	project.exe!hkpWorldAgentUtil::removeAgent(hkpAgentNnEntry * agent) Line 180	C++
 	project.exe!hkpMultiThreadedSimulation::MtEntityEntityBroadPhaseListener::removeCollisionPair(hkpTypedBroadPhaseHandlePair & pair) Line 357	C++
 	project.exe!hkpTypedBroadPhaseDispatcher::removePairs(hkpTypedBroadPhaseHandlePair * deletedPairs, int numDeletedPairs) Line 65	C++
 	project.exe!hkpSingleThreadedJobsOnIsland::cpuBroadPhaseJob(hkpMtThreadStructure & tl, hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & nextJobOut) Line 206	C++
 	project.exe!hkpMultiThreadedSimulation::processNextJob(hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & job) Line 198	C++
 	project.exe!hkJobQueue::processAllJobs(bool addTimers) Line 559	C++
 	project.exe!hkCpuJobThreadPool::workerFunction(void * workLoad) Line 76	C++
 	project.exe!hkCpuThreadPool::threadMain(void * v) Line 144	C++

 

My call stack on error time(When i create all boxes and then start simulation):

>	project.exe!hkAgentNnMachine_DestroyAgent(hkpAgentNnTrack & track, hkpAgentNnEntry * entry, hkpCollisionDispatcher * dispatcher, hkpConstraintOwner & constraintOwner) Line 367	C++
 	project.exe!hkpWorldAgentUtil::removeAgent(hkpAgentNnEntry * agent) Line 180	C++
 	project.exe!hkpMultiThreadedSimulation::MtEntityEntityBroadPhaseListener::removeCollisionPair(hkpTypedBroadPhaseHandlePair & pair) Line 357	C++
 	project.exe!hkpTypedBroadPhaseDispatcher::removePairs(hkpTypedBroadPhaseHandlePair * deletedPairs, int numDeletedPairs) Line 65	C++
 	project.exe!hkpSingleThreadedJobsOnIsland::cpuBroadPhaseJob(hkpMtThreadStructure & tl, hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & nextJobOut) Line 206	C++
 	project.exe!hkpMultiThreadedSimulation::processNextJob(hkJobQueue & jobQueue, hkJobQueue::JobQueueEntry & job) Line 198	C++
 	project.exe!hkJobQueue::processAllJobs(bool addTimers) Line 559	C++
 	project.exe!hkCpuJobThreadPool::workerFunction(void * workLoad) Line 76	C++
 	project.exe!hkCpuThreadPool::threadMain(void * v) Line 144	C++
 	ntdll.dll!77a59f72()	Unknown
 	[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
 	ntdll.dll!77a59f45()	Unknown

 

Thank you for any help.

H.Ahmadi

How to measure accident/collide power?

$
0
0

Hi

I'm using a hkpContactListener callback listener for measuring my vehicle body accident power, but i didn't success to found any useful data for estimating accident power on the callback function and using hkpContactPointEvent& event parameter!

How can i estimate accident/collide power? that power is need to do some game logics such as body deformation/player scoring and ...

Here is my listener, now i'm using "getSeparatingVelocity" but that is not correct and don't give me correct value for the vehicle accident power:

class BodyContactListener : public hkpContactListener
	{
	public:
		void contactPointCallback( const hkpContactPointEvent& event )
		{
			if ( event.m_contactPointProperties->m_flags & hkContactPointMaterial::CONTACT_IS_NEW )
			{
				float velocity=event.getSeparatingVelocity();
				if (velocity>1.0)
				{
					hkpRigidBody* body = event.getBody( event.m_source );
					hkContactPoint cp = *event.m_contactPoint;
					hkVector4 position=cp.getPosition();
					              //some game-play stuffs
				}
			}
		}
	};

Thank you in advance for any help.

H.Ahmadi

Asynchronous simulation, control and vehicles

$
0
0

Hello, I'm using hk2011_2_0_r1 Havok version in attempts to create fully deterministic engine. To ensure maximum FPS while keeping fixed delta time on physics simulation, I've got in touch with asynchronous stepping. But I have concerns regarding determinism of my logic over the world one's, and vehicle's visual representation.

First issue that is most important to me:

hkpWorld::setFrameTimeMarker() is seem to advance time further by supplied delta time, so hkpWorld::getCurrentTime() returns value appropriate for hkpRigidBody::approxTransformAt() to compute rigidbody's actual position for the rendering frame. This looks smooth as long as I only call corresponding functions once per frame, to sync visual objects with actual positions before rendering the frame. But, my goal is also in deterministic control, which is has to happen in strictly controlled moments of time, just like the solver's TOI events.

I've implemented own event timer and experimented with interfering into the simulation in between PSI steps, such as adding and removing bodies and changing their velocity, and Havok accepts such interfere very well and smooth. But I only managed to do so by decreasing simulation rate to deltaTime(1.0/15.0), so my FPS was high enough to have few frames between the steps, and my event timer would have more chances to check for events. But, events are fired over the current frame's state of the world, but just as TOI events, they has to be solved exactly at specified moment in time, rather than current, and princip by how hkpWorld::setFrameTimeMarker() is operating is restricting me from travelling a little back in time to affect rigid bodies when event commands to. I don't think I need entire world state to be changed, usually I only need only one specified rigid body's transform to be exact. Maybe I could calculate how much event is late, and substract that value from world's current time to get approx transform, but that seems too dirty. So what can I do to implement TOI-level accuracy from the outside code?

Second issue is a little bothersome:

The moment I started with asynchronous simulation, vehicle's wheels went out of sync. I found out that hkpVehicleInstance::calcCurrentPositionAndRotation(), which is responsible for wheels position calculation, is always returns their transform as of hkpWorld::getCurrentPsiTime(), rather than getCurrentTime(), and I found no ways to feed it with current time.

Considering vehicle still needs to store spring value from both current and previous frame, and additionally such way can be stored position too, I thought I could fix that function by myself, but couldn't by known reasons. I still can store wheel's transform from previous frame manually and interpolate, but is this the best way to do so?



//Additionally, can I ask, why is some basic code considered to be locked? I understand, that Havok is proprietary engine, which know-hows is protected, but still I was little puzzled when I didn't found vehicle's .cpp file. Ray-cast, and even shape-cast vehicle physics is fairly simple, when you know what you should do, and vehicle SDK's realisation could be bold addition to all the tutorials on vehicle physics widely available. Though, Havok vehicle SDK is more than just wheel physics, but character controller state machine is much lesser concept to be protected. And when I found no descriptors of constrains, I found myself wondering, how I even going to begin writing own, documentation has nothing about constraints implementation logic.


Problems to add an entity in havok world

$
0
0

Hi,

I am currently adding an entity into havok world ,  and encounter with some problems. Here's my code (as a sample)

	//get current havok world, I find it on Docs
	vHavokPhysicsModule *pPhysMod = vHavokPhysicsModule::GetInstance();
	hkpWorld *pWorld = pPhysMod->GetPhysicsWorld();

	hkpCylinderShape *hcs=new hkpCylinderShape(hkVector4(BASE_POSITION.x,BASE_POSITION.y,BASE_POSITION.z),hkVector4(BASE_POSITION.x,BASE_POSITION.y,BASE_POSITION.z+1000),100.0);

	hkpEntity *pEntity=new hkpEntity(hkFinishLoadedObjectFlag());
	pEntity->setShape(hcs);

	//add a lock in case two threads attempting to change the world
	pWorld->lock();//cause crash down
	//pWorld->addEntity(pEntity,HK_ENTITY_ACTIVATION_DO_ACTIVATE);
	pWorld->unlock();

And I get my application crash down if I uncomment the pWorld->addEntity(...).

I don't know whether it's because I get the current havok world wrong or I addEntity wrong.

Thanks in advance for any help.

Dezhi.J

I can't load my custom shaderlib for a custom postprocess

$
0
0

I creat a shaderlib called dis.shaderlib in Shader Editor Layout.

It's located in my project folder. I add a pixel shader on it . also it has been compiled.

in my program :  BOOL bResult = Vision::Shaders.LoadShaderLibrary("C:\\svn\\Assets\\distortion.ShaderLib", SHADERLIBFLAG_NONE) != NULL;

but bResult always returns NULL .  This shader is used for a custom postprocess.  Could you give me a custom postprocess example(not glow or Tonemapping ) to show me how to use a custom postprocess. Thanks a lot!

 

Long, kai

issue with ultra-minimal custom hkpBvTreeShape

$
0
0

Hi,

I'm attempting to create a custom hkpBvTreeShape. I've created the smallest possible testcase, dropping a box onto a ultra-minimal tree shape.

https://gist.github.com/jmkinzer/eceba1ea3b8763ebdbae

The error: Y:\NightlyJobs\07-18-Thu-01\Source\Physics2012/Dynamics/Entity/hkpRigidBody.inl(141): [0x49DA7B54] Assert: Point passed to hkpRigidBody::getPointVelocity is invalid.

The Stack trace: y:\nightlyjobs\07-18-thu-01\source\physics2012\collide\agent3\machine\nn\hkpagentnnmachine.cpp(714):'hkAgentNnMachine_ProcessTrack'

However based on what I see below I believe the root cause is further upstream. Note the assert occurs right when the box intersects with the tree aabb (I created a debug geometry for my tree to visualize this... attached is the extremely uninteresting vdb movie as well).

I have breakpoints set on all the tree functions. Only 2 methods are ever called. Initially:

void VolumeTree::getAabb(const hkTransform& localToWorld, hkReal tolerance, hkAabb& out) const
{
	// harcode some arbitrary bounds for now (when the shape is added to the world it's given a position of 0,0,0)
	hkVector4 v0(-5, -5, -5, 0);
	hkVector4 v1(5, 5, 5, 0);
	out.m_min = v0;
	out.m_max = v1;
}

And then when the intersection occurs:

void VolumeTree::queryAabb(const hkAabb& aabb, hkArray<hkpShapeKey>& hits) const
{
	hkFloat32 x1 = aabb.m_min.getComponent<0>().getReal(), y1 = aabb.m_min.getComponent<1>().getReal(), z1 = aabb.m_min.getComponent<2>().getReal();
	hkFloat32 x2 = aabb.m_max.getComponent<0>().getReal(), y2 = aabb.m_max.getComponent<1>().getReal(), z2 = aabb.m_max.getComponent<2>().getReal();
	// sz is 2147094796 !!??
	int sz = hits.getSize();
}

What's quite surprising in the latter function is the 'hits' array has clearly invalid data, and throws an assertion if I attempt to add to it. Almost seems like some kind of stack corruption? Anyhow, I feel like I must be missing some quite obvious configuration setting or override... I'm more or less stuck at this point however due to the black-box nature of the beast. Any clues would be really appreciated!

Thanks,

Jason

Downloadtest.zip

small clarification on source code comments regarding shape keys

$
0
0

Hi Havok Team,

Right now I have a custom hkpBvTreeShape returning shape keys that point to triangles. I would ideally like to generate and discard these tris on the fly. However, I was reading the comments below for hkpShapeContainer and am now unsure whether Havok will react well to that (the highlighted sections seem somewhat contradictory?).

To be precise: what is the expected lifetime of a shape key? Can the shapes they refer to change or become non-existent between (for example) simulation steps -or- should a key be considered immutable for the lifetime of the rigid body (in this case my tree) once the key been handed to Havok?

Thanks for the assistance!

Jason

/// Gets a child shape using a shape key.
/// This function must return a child shape pointer. This is only called internally by
/// the collision detection system after having called getFirstKey() or getNextKey().
/// If you have shape keys that are invalid, you must implement getNextKey() in such
/// a way that it skips over these shapes./// Important Note: It is assumed by the system that a shape key, if valid (i.e., returned by
/// getNextkey()) will always remain valid.///
/// Notes:
///     - You can return a pointer to a shape.
///     - Or you can construct a shape in place in the buffer and return a pointer to that buffer.///       E.g., hkpMeshShape uses this buffer for temporarily created triangles.
///       hkpListShape does not use the buffer as it already has shape instances.///       \b Attention: When the buffer gets erased, no destructor will be called.
///     - The buffer must be 16 byte aligned.
virtual const hkpShape* getChildShape( hkpShapeKey key, hkpShapeBuffer& buffer ) const = 0;

 

Welding causes Visual debugger to not respond?

$
0
0

Hellio. I've tried to send my mopp code through the welding utility which seems to work, but when I try to visualize it in the debugger, the debugger freezes for a really long time and is basically unusable. If I turn off the welding in my code, the debugger works as normal. What could be wrong? Thank you for any help with this, I'm trying to get rid of the character "bouncing" over edges. I can also see that my program is basically stalling at the time stepping for havok -

engineMgr->getHvkWorld()->stepMultithreaded( engineMgr->gethkJobQueue(), engineMgr->gethkJobThreadPool(), evt.timeSinceLastFrame);

I also tried just using single threaded havok and it stalls as well.

 

Viewing all 168 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>