Change CTransform4f to inherit from CMatrix4f

This commit is contained in:
parax0
2016-04-08 19:16:26 -06:00
parent 876cb0e737
commit dfdbed24c4
13 changed files with 124 additions and 130 deletions

View File

@@ -142,7 +142,7 @@ void CDrawUtil::DrawCube(const CColor& Color)
void CDrawUtil::DrawCube(const CVector3f& Position, const CColor& Color)
{
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Position).ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Position);
CGraphics::UpdateMVPBlock();
UseColorShader(Color);
DrawCube();
@@ -172,7 +172,7 @@ void CDrawUtil::DrawWireCube(const CAABox& kAABox, const CColor& kColor)
CTransform4f Transform;
Transform.Scale(kAABox.Size());
Transform.Translate(kAABox.Center());
CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = Transform;
CGraphics::UpdateMVPBlock();
UseColorShader(kColor);
@@ -204,7 +204,7 @@ void CDrawUtil::DrawWireSphere(const CVector3f& Position, float Radius, const CC
CTransform4f Transform;
Transform.Scale(Radius);
Transform.Translate(Position);
CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = Transform;
CGraphics::UpdateMVPBlock();
// Set other render params
@@ -223,7 +223,7 @@ void CDrawUtil::DrawBillboard(CTexture* pTexture, const CVector3f& Position, con
Init();
// Create translation-only model matrix
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Position).ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Position);
CGraphics::UpdateMVPBlock();
// Set uniforms
@@ -252,7 +252,7 @@ void CDrawUtil::DrawLightBillboard(ELightType Type, const CColor& LightColor, co
Init();
// Create translation-only model matrix
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Position).ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Position);
CGraphics::UpdateMVPBlock();
// Set uniforms

View File

@@ -46,7 +46,7 @@ void CRenderBucket::Sort(CCamera* pCamera)
float Intensity = 1.f - (Dot / 50.f);
CColor CubeColor(Intensity, Intensity, Intensity, 1.f);
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Point).ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Point);
CGraphics::UpdateMVPBlock();
CDrawUtil::DrawCube(CubeColor);
}

View File

@@ -190,7 +190,7 @@ void CRenderer::RenderBloom()
{
CDrawUtil::UseTextureShader(skTintColors[iPass]);
CVector3f Translate(skHOffset[iPass] * BloomHScale, 0.f, 0.f);
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Translate).ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Translate);
CGraphics::UpdateMVPBlock();
glBlendFunc(GL_ONE, GL_ONE);
CDrawUtil::DrawSquare();
@@ -210,7 +210,7 @@ void CRenderer::RenderBloom()
{
CDrawUtil::UseTextureShader(skTintColors[iPass]);
CVector3f Translate(0.f, skVOffset[iPass] * BloomVScale, 0.f);
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Translate).ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = CTransform4f::TranslationMatrix(Translate);
CGraphics::UpdateMVPBlock();
glBlendFunc(GL_ONE, GL_ONE);
CDrawUtil::DrawSquare();

View File

@@ -101,7 +101,6 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
GlyphTransform.Scale(CVector3f((float) pGlyph->Width / 2, (float) pGlyph->Height, 1.f));
GlyphTransform.Scale(Scale);
GlyphTransform.Translate(CVector3f(XTrans, YTrans, 0.f));
CMatrix4f Glyph4f = GlyphTransform.ToMatrix4f();
// Get glyph layer
u8 GlyphLayer = pGlyph->RGBAChannel;
@@ -109,7 +108,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
else if (mTextureFormat == 8) GlyphLayer = 3;
// Load shader uniforms, buffer texture
glUniformMatrix4fv(ModelMtxLoc, 1, GL_FALSE, (GLfloat*) &Glyph4f);
glUniformMatrix4fv(ModelMtxLoc, 1, GL_FALSE, (GLfloat*) &GlyphTransform);
smGlyphVertices.BufferAttrib(eTex0, &pGlyph->TexCoords);
// Draw fill

View File

@@ -84,7 +84,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/)
CTransform4f Transform;
Transform.Scale(0.025f);
Transform.Translate(pBone->AbsolutePosition());
CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = Transform;
CGraphics::UpdateMVPBlock();
CDrawUtil::DrawSphere(CColor::skWhite);

View File

@@ -124,7 +124,7 @@ void CSceneNode::SetInheritance(bool InheritPos, bool InheritRot, bool InheritSc
void CSceneNode::LoadModelMatrix()
{
CGraphics::sMVPBlock.ModelMatrix = Transform().ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = Transform();
CGraphics::UpdateMVPBlock();
}

View File

@@ -242,7 +242,7 @@ void CScriptNode::DrawSelection()
CTransform4f Transform;
Transform.Rotate(AbsoluteRotation());
Transform.Translate(AbsolutePosition());
CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f();
CGraphics::sMVPBlock.ModelMatrix = Transform;
CGraphics::UpdateMVPBlock();
CGraphics::sPixelBlock.TintColor = CColor::skWhite;