This commit is contained in:
Leonardo Zide
2021-03-20 17:00:30 -07:00
4 changed files with 13 additions and 7 deletions
+3
View File
@@ -110,6 +110,9 @@ bool lcContext::InitializeRenderer()
void lcContext::ShutdownRenderer() void lcContext::ShutdownRenderer()
{ {
if (!mGlobalOffscreenContext)
return;
mGlobalOffscreenContext->MakeCurrent(); mGlobalOffscreenContext->MakeCurrent();
lcContext* Context = mGlobalOffscreenContext.get(); lcContext* Context = mGlobalOffscreenContext.get();
+8 -6
View File
@@ -573,6 +573,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
{ {
const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices; const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices;
lcArray<quint32> IndexRemap(DataVertices.GetSize()); lcArray<quint32> IndexRemap(DataVertices.GetSize());
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
if (!TextureMap) if (!TextureMap)
{ {
@@ -589,7 +590,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
Index = AddVertex(Position, true); Index = AddVertex(Position, true);
else else
{ {
lcVector3 Normal = lcNormalize(lcMul30(DataVertex.Normal, Transform)); lcVector3 Normal = lcNormalize(lcMul(DataVertex.Normal, NormalTransform));
if (InvertNormals) if (InvertNormals)
Normal = -Normal; Normal = -Normal;
Index = AddVertex(Position, Normal, true); Index = AddVertex(Position, Normal, true);
@@ -601,7 +602,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
Index = AddTexturedVertex(Position, DataVertex.TexCoord, true); Index = AddTexturedVertex(Position, DataVertex.TexCoord, true);
else else
{ {
lcVector3 Normal = lcNormalize(lcMul30(DataVertex.Normal, Transform)); lcVector3 Normal = lcNormalize(lcMul(DataVertex.Normal, NormalTransform));
if (InvertNormals) if (InvertNormals)
Normal = -Normal; Normal = -Normal;
Index = AddTexturedVertex(Position, Normal, DataVertex.TexCoord, true); Index = AddTexturedVertex(Position, Normal, DataVertex.TexCoord, true);
@@ -625,7 +626,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
Index = AddTexturedVertex(Position, TexCoord, true); Index = AddTexturedVertex(Position, TexCoord, true);
else else
{ {
lcVector3 Normal = lcNormalize(lcMul30(DataVertex.Normal, Transform)); lcVector3 Normal = lcNormalize(lcMul(DataVertex.Normal, NormalTransform));
if (InvertNormals) if (InvertNormals)
Normal = -Normal; Normal = -Normal;
Index = AddTexturedVertex(Position, Normal, TexCoord, true); Index = AddTexturedVertex(Position, Normal, TexCoord, true);
@@ -696,6 +697,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
{ {
const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices; const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices;
quint32 BaseIndex; quint32 BaseIndex;
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
if (!TextureMap) if (!TextureMap)
{ {
@@ -709,7 +711,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
const lcMeshLoaderVertex& SrcVertex = DataVertices[SrcVertexIdx]; const lcMeshLoaderVertex& SrcVertex = DataVertices[SrcVertexIdx];
lcMeshLoaderVertex& DstVertex = mVertices.Add(); lcMeshLoaderVertex& DstVertex = mVertices.Add();
DstVertex.Position = lcMul31(SrcVertex.Position, Transform); DstVertex.Position = lcMul31(SrcVertex.Position, Transform);
DstVertex.Normal = lcNormalize(lcMul30(SrcVertex.Normal, Transform)); DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform));
if (InvertNormals) if (InvertNormals)
DstVertex.Normal = -DstVertex.Normal; DstVertex.Normal = -DstVertex.Normal;
DstVertex.NormalWeight = SrcVertex.NormalWeight; DstVertex.NormalWeight = SrcVertex.NormalWeight;
@@ -732,7 +734,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
lcVector2 TexCoord = lcCalculateTexCoord(Position, TextureMap); lcVector2 TexCoord = lcCalculateTexCoord(Position, TextureMap);
DstVertex.Position = Position; DstVertex.Position = Position;
DstVertex.Normal = lcNormalize(lcMul30(SrcVertex.Normal, Transform)); DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform));
if (InvertNormals) if (InvertNormals)
DstVertex.Normal = -DstVertex.Normal; DstVertex.Normal = -DstVertex.Normal;
DstVertex.NormalWeight = SrcVertex.NormalWeight; DstVertex.NormalWeight = SrcVertex.NormalWeight;
@@ -1240,7 +1242,7 @@ lcMesh* lcLibraryMeshData::CreateMesh()
} }
else else
{ {
quint16 BaseVertex = BaseConditionalVertices[LodIdx]; quint32 BaseVertex = BaseConditionalVertices[LodIdx];
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx++) for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx++)
*Index++ = BaseVertex + SrcSection->mIndices[IndexIdx]; *Index++ = BaseVertex + SrcSection->mIndices[IndexIdx];
+1
View File
@@ -659,6 +659,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
Piece->SetColorCode(ColorCode); Piece->SetColorCode(ColorCode);
Piece->VerifyControlPoints(ControlPoints); Piece->VerifyControlPoints(ControlPoints);
Piece->SetControlPoints(ControlPoints); Piece->SetControlPoints(ControlPoints);
ControlPoints.RemoveAll();
if (Piece->mPieceInfo->IsModel() && Piece->mPieceInfo->GetModel()->IncludesModel(this)) if (Piece->mPieceInfo->IsModel() && Piece->mPieceInfo->GetModel()->IncludesModel(this))
{ {
@@ -28,5 +28,5 @@ void main()
if (Cross1 * Cross2 >= 0.0) if (Cross1 * Cross2 >= 0.0)
gl_Position = Position; gl_Position = Position;
else else
gl_Position = vec4(2.0, 2.0, 2.0, 1.0); gl_Position = vec4(p1.x, p1.y, 2.0, 1.0);
} }