This commit is contained in:
Leonardo Zide 2021-03-20 17:00:30 -07:00
commit 8adf3502c0
4 changed files with 13 additions and 7 deletions

View file

@ -110,6 +110,9 @@ bool lcContext::InitializeRenderer()
void lcContext::ShutdownRenderer()
{
if (!mGlobalOffscreenContext)
return;
mGlobalOffscreenContext->MakeCurrent();
lcContext* Context = mGlobalOffscreenContext.get();

View file

@ -573,6 +573,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
{
const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices;
lcArray<quint32> IndexRemap(DataVertices.GetSize());
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
if (!TextureMap)
{
@ -589,7 +590,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
Index = AddVertex(Position, true);
else
{
lcVector3 Normal = lcNormalize(lcMul30(DataVertex.Normal, Transform));
lcVector3 Normal = lcNormalize(lcMul(DataVertex.Normal, NormalTransform));
if (InvertNormals)
Normal = -Normal;
Index = AddVertex(Position, Normal, true);
@ -601,7 +602,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
Index = AddTexturedVertex(Position, DataVertex.TexCoord, true);
else
{
lcVector3 Normal = lcNormalize(lcMul30(DataVertex.Normal, Transform));
lcVector3 Normal = lcNormalize(lcMul(DataVertex.Normal, NormalTransform));
if (InvertNormals)
Normal = -Normal;
Index = AddTexturedVertex(Position, Normal, DataVertex.TexCoord, true);
@ -625,7 +626,7 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
Index = AddTexturedVertex(Position, TexCoord, true);
else
{
lcVector3 Normal = lcNormalize(lcMul30(DataVertex.Normal, Transform));
lcVector3 Normal = lcNormalize(lcMul(DataVertex.Normal, NormalTransform));
if (InvertNormals)
Normal = -Normal;
Index = AddTexturedVertex(Position, Normal, TexCoord, true);
@ -696,6 +697,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
{
const lcArray<lcMeshLoaderVertex>& DataVertices = Data.mVertices;
quint32 BaseIndex;
const lcMatrix33 NormalTransform = lcMatrix33Transpose(lcMatrix33(lcMatrix44Inverse(Transform)));
if (!TextureMap)
{
@ -709,7 +711,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
const lcMeshLoaderVertex& SrcVertex = DataVertices[SrcVertexIdx];
lcMeshLoaderVertex& DstVertex = mVertices.Add();
DstVertex.Position = lcMul31(SrcVertex.Position, Transform);
DstVertex.Normal = lcNormalize(lcMul30(SrcVertex.Normal, Transform));
DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform));
if (InvertNormals)
DstVertex.Normal = -DstVertex.Normal;
DstVertex.NormalWeight = SrcVertex.NormalWeight;
@ -732,7 +734,7 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
lcVector2 TexCoord = lcCalculateTexCoord(Position, TextureMap);
DstVertex.Position = Position;
DstVertex.Normal = lcNormalize(lcMul30(SrcVertex.Normal, Transform));
DstVertex.Normal = lcNormalize(lcMul(SrcVertex.Normal, NormalTransform));
if (InvertNormals)
DstVertex.Normal = -DstVertex.Normal;
DstVertex.NormalWeight = SrcVertex.NormalWeight;
@ -1240,7 +1242,7 @@ lcMesh* lcLibraryMeshData::CreateMesh()
}
else
{
quint16 BaseVertex = BaseConditionalVertices[LodIdx];
quint32 BaseVertex = BaseConditionalVertices[LodIdx];
for (int IndexIdx = 0; IndexIdx < SrcSection->mIndices.GetSize(); IndexIdx++)
*Index++ = BaseVertex + SrcSection->mIndices[IndexIdx];

View file

@ -659,6 +659,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
Piece->SetColorCode(ColorCode);
Piece->VerifyControlPoints(ControlPoints);
Piece->SetControlPoints(ControlPoints);
ControlPoints.RemoveAll();
if (Piece->mPieceInfo->IsModel() && Piece->mPieceInfo->GetModel()->IncludesModel(this))
{

View file

@ -28,5 +28,5 @@ void main()
if (Cross1 * Cross2 >= 0.0)
gl_Position = Position;
else
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
gl_Position = vec4(p1.x, p1.y, 2.0, 1.0);
}