Пример #1
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ReleaseData: delete anything allocated by the model
void CModel::ReleaseData()
{
	rtl_FreeAligned(m_BoneMatrices);

	for (size_t i = 0; i < m_Props.size(); ++i)
		delete m_Props[i].m_Model;
	m_Props.clear();

	m_pModelDef = CModelDefPtr();
}
Пример #2
0
// Free all resources on destruction or when a layout parameter changes
void VertexArray::Free()
{
	rtl_FreeAligned(m_BackingStore);
	m_BackingStore = 0;
	
	if (m_VB)
	{
		g_VBMan.Release(m_VB);
		m_VB = 0;
	}
}
Пример #3
0
// Updated transforms
void PolygonSortModelRenderer::UpdateModelData(CModel* model, void* data, int updateflags)
{
    PSModel* psmdl = (PSModel*)data;

    if (updateflags & (RENDERDATA_UPDATE_VERTICES|RENDERDATA_UPDATE_COLOR))
    {
        CModelDefPtr mdef = model->GetModelDef();
        size_t numVertices = mdef->GetNumVertices();

        // build vertices

        // allocate working space for computing normals
        if (numVertices > m->normalsNumVertices)
        {
            rtl_FreeAligned(m->normals);

            size_t newSize = round_up_to_pow2(numVertices);
            m->normals = (char*)rtl_AllocateAligned(newSize*16, 16);
            m->normalsNumVertices = newSize;
        }

        VertexArrayIterator<CVector3D> Position = psmdl->m_Position.GetIterator<CVector3D>();
        VertexArrayIterator<CVector3D> Normal = VertexArrayIterator<CVector3D>(m->normals, 16);

        ModelRenderer::BuildPositionAndNormals(model, Position, Normal);

        VertexArrayIterator<SColor4ub> Color = psmdl->m_Color.GetIterator<SColor4ub>();

        ModelRenderer::BuildColor4ub(model, Normal, Color);

        // upload everything to vertex buffer
        psmdl->m_Array.Upload();
    }

    // resort model indices from back to front, according to the view camera position - and store
    // the returned sqrd distance to the centre of the nearest triangle
    // Use the view camera instead of the cull camera because:
    //  a) polygon sorting implicitly uses the view camera (and changing that would be costly)
    //  b) using the cull camera is likely not interesting from a debugging POV
    PROFILE_START( "sorting transparent" );

    CMatrix3D worldToCam;
    g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam);

    psmdl->BackToFrontIndexSort(worldToCam);
    PROFILE_END( "sorting transparent" );
}
Пример #4
0
static void FreeAligned(void* pointer, size_t UNUSED(size))
{
	return rtl_FreeAligned(pointer);
}
Пример #5
0
// Free the backing store to save some memory
void VertexArray::FreeBackingStore()
{
	rtl_FreeAligned(m_BackingStore);
	m_BackingStore = 0;
}
Пример #6
0
PolygonSortModelRenderer::~PolygonSortModelRenderer()
{
    rtl_FreeAligned(m->normals);

    delete m;
}
Пример #7
0
static void UniqueRangeDeleterAligned(void* pointer, size_t UNUSED(size))
{
	return rtl_FreeAligned(pointer);
}