Fixed textures in subparts not working. Fixes #1011.

This commit is contained in:
Leonardo Zide
2026-03-09 22:19:16 -07:00
parent da29df623b
commit 4de2c822af
2 changed files with 24 additions and 26 deletions
+15 -5
View File
@@ -369,11 +369,16 @@ void lcMeshLoaderTypeData::AddMeshData(const lcMeshLoaderTypeData& Data, const l
if (SrcSection->mMaterial->Type != lcMeshLoaderMaterialType::Solid)
{
lcMeshLoaderTextureMap DstTextureMap = *TextureMap;
lcMeshLoaderTextureParams DstTextureMap;
if (TextureMap)
DstTextureMap = *TextureMap;
else
DstTextureMap = *SrcSection->mMaterial;
for (lcVector3& Point : DstTextureMap.Points)
Point = lcMul31(Point, Transform);
DstSection = AddSection(PrimitiveType, mMeshData->GetTexturedMaterial(ColorCode, DstTextureMap));
}
else if (TextureMap && SrcSection->mPrimitiveType == LC_MESH_TRIANGLES)
@@ -452,7 +457,12 @@ void lcMeshLoaderTypeData::AddMeshDataNoDuplicateCheck(const lcMeshLoaderTypeDat
if (SrcSection->mMaterial->Type != lcMeshLoaderMaterialType::Solid)
{
lcMeshLoaderTextureMap DstTextureMap = *TextureMap;
lcMeshLoaderTextureParams DstTextureMap;
if (TextureMap)
DstTextureMap = *TextureMap;
else
DstTextureMap = *SrcSection->mMaterial;
for (lcVector3& Point : DstTextureMap.Points)
Point = lcMul31(Point, Transform);
@@ -553,7 +563,7 @@ lcMeshLoaderMaterial* lcLibraryMeshData::GetMaterial(quint32 ColorCode)
return Material;
}
lcMeshLoaderMaterial* lcLibraryMeshData::GetTexturedMaterial(quint32 ColorCode, const lcMeshLoaderTextureMap& TextureMap)
lcMeshLoaderMaterial* lcLibraryMeshData::GetTexturedMaterial(quint32 ColorCode, const lcMeshLoaderTextureParams& TextureMap)
{
for (const std::unique_ptr<lcMeshLoaderMaterial>& Material : mMaterials)
{
+9 -21
View File
@@ -41,13 +41,17 @@ enum class lcMeshLoaderMaterialType
Spherical
};
struct lcMeshLoaderMaterial
struct lcMeshLoaderTextureParams
{
lcMeshLoaderMaterialType Type = lcMeshLoaderMaterialType::Solid;
quint32 Color = 16;
lcVector3 Points[3] = {};
float Angles[2] = {};
char Name[256] = {};
char Name[LC_MAXPATH] = {};
};
struct lcMeshLoaderMaterial : public lcMeshLoaderTextureParams
{
quint32 Color = 16;
};
class lcMeshLoaderSection
@@ -71,24 +75,8 @@ struct lcMeshLoaderFinalSection
char Name[256];
};
struct lcMeshLoaderTextureMap
struct lcMeshLoaderTextureMap : public lcMeshLoaderTextureParams
{
union lcTextureMapParams
{
lcTextureMapParams()
{
}
struct lcTextureMapSphericalParams
{
} Spherical;
} Params;
lcMeshLoaderMaterialType Type;
lcVector3 Points[3];
float Angles[2];
char Name[LC_MAXPATH];
bool Fallback = false;
bool Next = false;
};
@@ -182,7 +170,7 @@ public:
void AddMeshDataNoDuplicateCheck(const lcLibraryMeshData& Data, const lcMatrix44& Transform, quint32 CurrentColorCode, bool InvertWinding, bool InvertNormals, lcMeshLoaderTextureMap* TextureMap, lcMeshDataType OverrideDestIndex);
lcMeshLoaderMaterial* GetMaterial(quint32 ColorCode);
lcMeshLoaderMaterial* GetTexturedMaterial(quint32 ColorCode, const lcMeshLoaderTextureMap& TextureMap);
lcMeshLoaderMaterial* GetTexturedMaterial(quint32 ColorCode, const lcMeshLoaderTextureParams& TextureMap);
std::array<lcMeshLoaderTypeData, LC_NUM_MESHDATA_TYPES> mData;
bool mHasTextures;