forked from Mirrors/openclonk
Order submeshes so that opaque ones are rendered before non-opaque ones
parent
fc5a28ea20
commit
cfad8f67cd
|
@ -31,7 +31,6 @@ material Musket
|
||||||
diffuse 0.800000 0.800000 0.800000 1.000000
|
diffuse 0.800000 0.800000 0.800000 1.000000
|
||||||
specular 0.000000 0.000000 0.000000 1.000000 12.500000
|
specular 0.000000 0.000000 0.000000 1.000000 12.500000
|
||||||
emissive 0.000000 0.000000 0.000000 1.000000
|
emissive 0.000000 0.000000 0.000000 1.000000
|
||||||
scene_blend alpha_blend
|
|
||||||
texture_unit
|
texture_unit
|
||||||
{
|
{
|
||||||
texture musket.png
|
texture musket.png
|
||||||
|
@ -40,4 +39,4 @@ material Musket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ material Chest
|
||||||
diffuse 0.640000 0.640000 0.640000 1.000000
|
diffuse 0.640000 0.640000 0.640000 1.000000
|
||||||
specular 0.500000 0.500000 0.500000 1.000000 12.500000
|
specular 0.500000 0.500000 0.500000 1.000000 12.500000
|
||||||
emissive 0.000000 0.000000 0.000000 1.000000
|
emissive 0.000000 0.000000 0.000000 1.000000
|
||||||
scene_blend alpha_blend
|
|
||||||
texture_unit
|
texture_unit
|
||||||
{
|
{
|
||||||
texture chest.png
|
texture chest.png
|
||||||
|
|
|
@ -178,8 +178,8 @@ bool C4DefGraphics::LoadMesh(C4Group &hGroup, StdMeshSkeletonLoader& loader)
|
||||||
return false;
|
return false;
|
||||||
delete[] buf;
|
delete[] buf;
|
||||||
|
|
||||||
// Create mirrored animations (#401)
|
// Create mirrored animations (#401), order submeshes
|
||||||
Mesh->MirrorAnimations();
|
Mesh->PostInit();
|
||||||
}
|
}
|
||||||
catch (const std::runtime_error& ex)
|
catch (const std::runtime_error& ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,6 +30,15 @@ std::vector<StdMeshInstance::SerializableValueProvider::IDBase*>* StdMeshInstanc
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
// Helper to sort submeshes so that opaque ones appear before non-opaque ones
|
||||||
|
struct StdMeshSubMeshVisibilityCmpPred
|
||||||
|
{
|
||||||
|
bool operator()(const StdSubMesh& first, const StdSubMesh& second)
|
||||||
|
{
|
||||||
|
return first.GetMaterial().IsOpaque() > second.GetMaterial().IsOpaque();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Helper to sort faces for FaceOrdering
|
// Helper to sort faces for FaceOrdering
|
||||||
struct StdMeshInstanceFaceOrderingCmpPred
|
struct StdMeshInstanceFaceOrderingCmpPred
|
||||||
{
|
{
|
||||||
|
@ -989,7 +998,7 @@ void StdMesh::MirrorAnimation(const StdStrBuf& name, const StdMeshAnimation& ani
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StdMesh::MirrorAnimations()
|
void StdMesh::PostInit()
|
||||||
{
|
{
|
||||||
// Mirror .R and .L animations without counterpart
|
// Mirror .R and .L animations without counterpart
|
||||||
for(std::map<StdCopyStrBuf, StdMeshAnimation>::iterator iter = Animations.begin(); iter != Animations.end(); ++iter)
|
for(std::map<StdCopyStrBuf, StdMeshAnimation>::iterator iter = Animations.begin(); iter != Animations.end(); ++iter)
|
||||||
|
@ -1005,6 +1014,9 @@ void StdMesh::MirrorAnimations()
|
||||||
MirrorAnimation(buf, iter->second);
|
MirrorAnimation(buf, iter->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Order submeshes so that opaque submeshes come before non-opaque ones
|
||||||
|
std::sort(SubMeshes.begin(), SubMeshes.end(), StdMeshSubMeshVisibilityCmpPred());
|
||||||
}
|
}
|
||||||
|
|
||||||
StdSubMeshInstance::StdSubMeshInstance(const StdSubMesh& submesh):
|
StdSubMeshInstance::StdSubMeshInstance(const StdSubMesh& submesh):
|
||||||
|
@ -1043,6 +1055,9 @@ void StdSubMeshInstance::SetMaterial(const StdMeshMaterial& material)
|
||||||
PassData[i].TexUnits.push_back(unit);
|
PassData[i].TexUnits.push_back(unit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Reorder this submesh so that opaque submeshes are drawn
|
||||||
|
// before non-opaque ones.
|
||||||
}
|
}
|
||||||
|
|
||||||
void StdMeshInstance::SerializableValueProvider::CompileFunc(StdCompiler* pComp)
|
void StdMeshInstance::SerializableValueProvider::CompileFunc(StdCompiler* pComp)
|
||||||
|
|
|
@ -277,7 +277,7 @@ public:
|
||||||
|
|
||||||
// TODO: This code should maybe better be placed in StdMeshLoader...
|
// TODO: This code should maybe better be placed in StdMeshLoader...
|
||||||
void MirrorAnimation(const StdStrBuf& name, const StdMeshAnimation& animation);
|
void MirrorAnimation(const StdStrBuf& name, const StdMeshAnimation& animation);
|
||||||
void MirrorAnimations();
|
void PostInit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddMasterBone(StdMeshBone* bone);
|
void AddMasterBone(StdMeshBone* bone);
|
||||||
|
|
Loading…
Reference in New Issue