Started work on build system
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
#include "brush.h"
|
||||
#include "baseentity.h"
|
||||
#include "cglm/mat4.h"
|
||||
#include "physics.h"
|
||||
#include "rendering.h"
|
||||
#include "tier0/platform.h"
|
||||
@@ -12,11 +14,13 @@ void CBrushEntity::Precache()
|
||||
|
||||
void CBrushEntity::Spawn()
|
||||
{
|
||||
/* physics don't support unindexed meshes, so generate indicies */
|
||||
CUtlBuffer<uint32_t> indicies(m_mesh.GetSize()*3);
|
||||
for (uint32_t i = 0;i<indicies.GetSize();i++)
|
||||
{
|
||||
indicies[i]=i;
|
||||
}
|
||||
/* copy over the triangles to a separate buffer, which will be used by physics */
|
||||
CUtlBuffer<Point<float>> triangles(m_mesh.GetSize()*3);
|
||||
uint32_t i = 0;
|
||||
for (auto tri: m_mesh)
|
||||
@@ -24,17 +28,10 @@ void CBrushEntity::Spawn()
|
||||
V_memcpy(&triangles[i],tri.location,36);
|
||||
i+=3;
|
||||
}
|
||||
/* use them */
|
||||
px_collider_params params = {};
|
||||
params.friction = 0.6;
|
||||
m_collider = px_trimesh((Point<float>*)triangles.GetMemory(), triangles.GetSize(), (uint32_t(*)[3])indicies.GetMemory(), indicies.GetSize()/3 ,params);
|
||||
//m_collider = px_box(4, 10, 1, params);
|
||||
px_matrix mat = {};
|
||||
mat.m[0] = 1;
|
||||
mat.m[5] = 1;
|
||||
mat.m[10] = 1;
|
||||
mat.m[15] = 1;
|
||||
px_rigidbody_params param = {};
|
||||
param.gravity_scale = 1;
|
||||
px_fixedbody(px, m_collider);
|
||||
};
|
||||
|
||||
@@ -44,6 +41,12 @@ void CBrushEntity::Destroy()
|
||||
}
|
||||
void CBrushEntity::Think( float fDelta )
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
void CBrushEntity::ReadParameter( const char *szName, const char *szValue )
|
||||
{
|
||||
CBaseEntity::ReadParameter(szName, szValue);
|
||||
};
|
||||
|
||||
|
||||
@@ -89,7 +92,7 @@ void C_BrushEntity::Spawn()
|
||||
}
|
||||
vertexBuffer->Unmap();
|
||||
|
||||
mesh = IBrushRenderer::CreateMesh();
|
||||
mesh = IMeshRenderer::CreateMesh();
|
||||
mesh->SetVertexBuffer(vertexBuffer);
|
||||
|
||||
};
|
||||
@@ -102,7 +105,16 @@ void C_BrushEntity::Think( float fDelta )
|
||||
{
|
||||
material.m.albedo = ITextureManager::GetTexture(pAlbedo);
|
||||
IRenderer::SetMaterial(&material);
|
||||
mat4 matrix;
|
||||
glm_mat4_zero(matrix);
|
||||
for (int i = 0; i < 9; i++) {
|
||||
matrix[i/3][i%3] = pEntity->m_matrix[i/3][i%3];
|
||||
}
|
||||
matrix[3][3] = 1;
|
||||
matrix[3][0] = pEntity->m_position[0];
|
||||
matrix[3][1] = pEntity->m_position[1];
|
||||
matrix[3][2] = pEntity->m_position[2];
|
||||
mesh->SetMatrix(matrix);
|
||||
mesh->Draw();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user