Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "physicsDevice.h"

using namespace engine::physics;

// Serialization.
#include <Common/Base/System/Io/IStream/hkIStream.h>
#include <Common/Base/Reflection/hkClass.h>
#include <Common/Base/Reflection/Registry/hkTypeInfoRegistry.h>
#include <Common/Serialize/Util/hkStructureLayout.h>
#include <Common/Serialize/Util/hkRootLevelContainer.h>
#include <Common/Serialize/Util/hkSerializeUtil.h>
#include <Physics/Utilities/Serialize/hkpPhysicsData.h>
#include <Common/Serialize/Util/hkLoader.h>

void load5()
{
	hkResource* m_loadedData;

	// Disable warnings
	hkError::getInstance().setEnabled(0xf03243ed, false); // 'm_contactRestingVelocity not set, setting it to REAL_MAX, so that the new collision restitution code will be disabled'
	hkError::getInstance().setEnabled(0x9fe65234, false);  // 'Unsupported simulation on type, setting to SIMULATION_TYPE_CONTINUOUS. See documentation on world stepping and time management'

	// Load the file
	hkSerializeUtil::ErrorDetails loadError;
	m_loadedData = hkSerializeUtil::load( "Item.hkt", &loadError);
	if ( !m_loadedData )
	{
		{
			HK_ASSERT3(0xa6451543, m_loadedData != HK_NULL, "Could not load file. The error is:\n" << loadError.defaultMessage.cString() );
		}
	}

	// Get the top level object in the file, which we know is a hkRootLevelContainer
	hkRootLevelContainer* container = m_loadedData->getContents<hkRootLevelContainer>();
	HK_ASSERT2(0xa6451543, container != HK_NULL, "Could not load root level object" );

	// Get the physics data
	hkpPhysicsData* physicsData = static_cast<hkpPhysicsData*>( container->findObjectByType( hkpPhysicsDataClass.getName() ) );
	HK_ASSERT2(0xa6451544, physicsData != HK_NULL, "Could not find physics data in root level object" );
	HK_ASSERT2(0xa6451535, physicsData->getWorldCinfo() != HK_NULL, "No physics cinfo in loaded file - cannot create a hkpWorld" );
	
	// Create a world and add the physics systems to it
	//hkpWorld* world = new hkpWorld( *physicsData->getWorldCinfo() );
	PHYSICSDEVICE.getWorld()->lock();

	// Register all collision agents
	//hkpAgentRegisterUtil::registerAllAgents( PHYSICSDEVICE.getWorld()->getCollisionDispatcher() );

	// Add all the physics systems to the world
	for ( int i = 0; i < physicsData->getPhysicsSystems().getSize(); ++i )
	{
		PHYSICSDEVICE.getWorld()->addPhysicsSystem( physicsData->getPhysicsSystems()[i] );
	}
	PHYSICSDEVICE.getWorld()->unlock();
	
	//I do not need export hkt file
	//hkSerializeUtil::saveTagfile( container, hkRootLevelContainerClass, hkOstream("out.hkt").getStreamWriter() );

	//-------------------------------------------------------------------

	// Re-enable warnings
	hkError::getInstance().setEnabled(0xf03243ed, true);
	hkError::getInstance().setEnabled(0x9fe65234, true);

	if ( PHYSICSDEVICE.getWorld() )
	{
		PHYSICSDEVICE.getWorld()->markForWrite();
		PHYSICSDEVICE.getWorld()->removeReference();
		//world = HK_NULL;
	}

	if ( m_loadedData )
	{
		m_loadedData->removeReference();
		m_loadedData = HK_NULL;
	}
}