improve rendering and physics
This commit is contained in:
@@ -197,11 +197,14 @@ HFunnyMesh CAssetManager::LoadMesh( const char *szName )
|
||||
}
|
||||
|
||||
|
||||
pMesh->m_nPositionCount = filesystem->Size(hMesh)/4;
|
||||
*pMesh = {};
|
||||
pMesh->m_nPositionCount = filesystem->Size(hMesh)/32*3;
|
||||
pMesh->m_pfPositions = new float[pMesh->m_nPositionCount];
|
||||
filesystem->Read( hMesh, pMesh->m_pfPositions, filesystem->Size(hMesh));
|
||||
pMesh->m_nIndiciesCount = 0;
|
||||
pMesh->m_puIndicies = 0;
|
||||
for ( int i = 0; i < filesystem->Size(hMesh) / 32; i++)
|
||||
{
|
||||
filesystem->Seek( hMesh, SEEKMODE_RELATIVE_START, 32*i);
|
||||
filesystem->Read( hMesh, &pMesh->m_pfPositions[i*3], 12);
|
||||
}
|
||||
|
||||
|
||||
return hAsset;
|
||||
@@ -251,16 +254,13 @@ HFunnyPhysics CAssetManager::LoadPhysics( const char *szName )
|
||||
return 0;
|
||||
}
|
||||
CUtlString szType = pTypeValue->GetStringValue();
|
||||
V_printf("%s\n", szType.GetString());
|
||||
if (szType == "Sphere")
|
||||
{
|
||||
pPhysics->m_hShape = g_pPhysics->CreateBall({1.0});
|
||||
}
|
||||
if (szType == "TriangleMesh")
|
||||
{
|
||||
V_printf("hi\n");
|
||||
IJSONValue *pMeshValue = pMainObject->GetValue("Mesh");
|
||||
V_printf("hi\n");
|
||||
if (!pMeshValue)
|
||||
{
|
||||
|
||||
@@ -269,11 +269,9 @@ HFunnyPhysics CAssetManager::LoadPhysics( const char *szName )
|
||||
return 0;
|
||||
}
|
||||
CUtlString szMesh = pMeshValue->GetStringValue();
|
||||
V_printf("%s\n", szMesh.GetString());
|
||||
HFunnyMesh hMesh = LoadMesh(szMesh);
|
||||
FunnyMesh_t *pMesh = GetMeshByIndex(hMesh);
|
||||
pPhysics->m_hShape = g_pPhysics->CreateTriangleMesh({pMesh->m_pfPositions, pMesh->m_nPositionCount});
|
||||
V_printf("%p\n", pPhysics->m_hShape);
|
||||
pPhysics->m_hShape = g_pPhysics->CreateTriangleMesh({pMesh->m_pfPositions, pMesh->m_nPositionCount, pMesh->m_puIndicies, pMesh->m_nIndiciesCount});
|
||||
pPhysics->m_hMesh = hMesh;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user