mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Switch from "is gltf" bool to source file format enum
This commit is contained in:
parent
f0abe80bcb
commit
3b6ec864b5
6 changed files with 25 additions and 13 deletions
|
@ -26,12 +26,21 @@ class ISceneManager;
|
|||
class SkinnedMesh : public IAnimatedMesh
|
||||
{
|
||||
public:
|
||||
|
||||
enum class SourceFormat {
|
||||
B3D,
|
||||
X,
|
||||
GLTF,
|
||||
OTHER,
|
||||
};
|
||||
|
||||
//! constructor
|
||||
SkinnedMesh() :
|
||||
SkinnedMesh(SourceFormat src_format) :
|
||||
EndFrame(0.f), FramesPerSecond(25.f),
|
||||
LastAnimatedFrame(-1), SkinnedLastFrame(false),
|
||||
HasAnimation(false), PreparedForSkinning(false),
|
||||
AnimateNormals(true), HardwareSkinning(false)
|
||||
AnimateNormals(true), HardwareSkinning(false),
|
||||
SrcFormat(src_format)
|
||||
{
|
||||
SkinningBuffers = &LocalBuffers;
|
||||
}
|
||||
|
@ -39,6 +48,10 @@ public:
|
|||
//! destructor
|
||||
virtual ~SkinnedMesh();
|
||||
|
||||
//! The source (file) format the mesh was loaded from.
|
||||
//! Important for legacy reasons pertaining to different mesh loader behavior.
|
||||
SourceFormat getSourceFormat() const { return SrcFormat; }
|
||||
|
||||
//! If the duration is 0, it is a static (=non animated) mesh.
|
||||
f32 getMaxFrameNumber() const override;
|
||||
|
||||
|
@ -339,10 +352,6 @@ public:
|
|||
return AllJoints;
|
||||
}
|
||||
|
||||
//! Whether the mesh originated from a glTF file.
|
||||
//! This is important for legacy reasons.
|
||||
bool isGltf() const { return IsGltf; }
|
||||
|
||||
protected:
|
||||
void checkForAnimation();
|
||||
|
||||
|
@ -387,13 +396,13 @@ protected:
|
|||
bool AnimateNormals;
|
||||
bool HardwareSkinning;
|
||||
|
||||
bool IsGltf = false;
|
||||
SourceFormat SrcFormat;
|
||||
};
|
||||
|
||||
// Interface for mesh loaders
|
||||
class SkinnedMeshBuilder : public SkinnedMesh {
|
||||
public:
|
||||
SkinnedMeshBuilder(bool is_gltf = false) : SkinnedMesh() { IsGltf = is_gltf; }
|
||||
SkinnedMeshBuilder(SourceFormat src_format) : SkinnedMesh(src_format) {}
|
||||
|
||||
//! loaders should call this after populating the mesh
|
||||
// returns *this, so do not try to drop the mesh builder instance
|
||||
|
|
|
@ -48,7 +48,7 @@ IAnimatedMesh *CB3DMeshFileLoader::createMesh(io::IReadFile *file)
|
|||
return 0;
|
||||
|
||||
B3DFile = file;
|
||||
AnimatedMesh = new scene::SkinnedMeshBuilder();
|
||||
AnimatedMesh = new scene::SkinnedMeshBuilder(SkinnedMesh::SourceFormat::B3D);
|
||||
ShowWarning = true; // If true a warning is issued if too many textures are used
|
||||
VerticesStart = 0;
|
||||
|
||||
|
|
|
@ -347,7 +347,8 @@ IAnimatedMesh* SelfType::createMesh(io::IReadFile* file)
|
|||
const char *filename = file->getFileName().c_str();
|
||||
try {
|
||||
tiniergltf::GlTF model = parseGLTF(file);
|
||||
irr_ptr<SkinnedMeshBuilder> mesh(new SkinnedMeshBuilder(true));
|
||||
irr_ptr<SkinnedMeshBuilder> mesh(new SkinnedMeshBuilder(
|
||||
SkinnedMesh::SourceFormat::GLTF));
|
||||
MeshExtractor extractor(std::move(model), mesh.get());
|
||||
try {
|
||||
extractor.load();
|
||||
|
|
|
@ -762,7 +762,7 @@ ISceneManager *CSceneManager::createNewSceneManager(bool cloneContent)
|
|||
//! Get a skinned mesh, which is not available as header-only code
|
||||
SkinnedMesh *CSceneManager::createSkinnedMesh()
|
||||
{
|
||||
return new SkinnedMesh();
|
||||
return new SkinnedMesh(SkinnedMesh::SourceFormat::OTHER);
|
||||
}
|
||||
|
||||
// creates a scenemanager
|
||||
|
|
|
@ -54,7 +54,7 @@ IAnimatedMesh *CXMeshFileLoader::createMesh(io::IReadFile *file)
|
|||
u32 time = os::Timer::getRealTime();
|
||||
#endif
|
||||
|
||||
AnimatedMesh = new SkinnedMeshBuilder();
|
||||
AnimatedMesh = new SkinnedMeshBuilder(SkinnedMesh::SourceFormat::X);
|
||||
|
||||
SkinnedMesh *res = nullptr;
|
||||
if (load(file)) {
|
||||
|
|
|
@ -974,7 +974,9 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
|
|||
if (auto *skinned_mesh = dynamic_cast<scene::SkinnedMesh *>(src_mesh)) {
|
||||
// Compatibility: Animated meshes, as well as static gltf meshes, are not scaled by BS.
|
||||
// See https://github.com/luanti-org/luanti/pull/16112#issuecomment-2881860329
|
||||
apply_bs = skinned_mesh->isStatic() && !skinned_mesh->isGltf();
|
||||
bool is_gltf = skinned_mesh->getSourceFormat() ==
|
||||
scene::SkinnedMesh::SourceFormat::GLTF;
|
||||
apply_bs = skinned_mesh->isStatic() && !is_gltf;
|
||||
// Nodes do not support mesh animation, so we clone the static pose.
|
||||
// This simplifies working with the mesh: We can just scale the vertices
|
||||
// as transformations have already been applied.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue