VOXEDIT: fixed loading animation models

master
Martin Gerhardy 2020-09-02 23:58:24 +02:00
parent deed428264
commit b5da9a7357
4 changed files with 24 additions and 4 deletions

View File

@ -62,6 +62,10 @@ bool MeshCache::loadMesh(const char* fullPath, voxel::Mesh& mesh) {
break;
}
}
if (!file->exists()) {
Log::error("Failed to load %s for any of the supported format extensions", fullPath);
return false;
}
voxel::VoxelVolumes volumes;
if (!voxelformat::loadVolumeFormat(file, volumes)) {
Log::error("Failed to load %s", file->name().c_str());

View File

@ -35,6 +35,10 @@ voxel::RawVolume* VolumeCache::loadVolume(const char* fullPath) {
break;
}
}
if (!file->exists()) {
Log::error("Failed to load %s for any of the supported format extensions", fullPath);
return nullptr;
}
voxel::VoxelVolumes volumes;
if (!voxelformat::loadVolumeFormat(file, volumes)) {
Log::error("Failed to load %s", file->name().c_str());

View File

@ -28,7 +28,7 @@ const char *SUPPORTED_VOXEL_FORMATS_SAVE = "vox,qbt,qb,binvox,cub,vxl,qef";
bool loadVolumeFormat(const io::FilePtr& filePtr, voxel::VoxelVolumes& newVolumes) {
if (!filePtr->exists()) {
Log::error("Failed to load model file %s", filePtr->name().c_str());
Log::error("Failed to load model file %s. Doesn't exist.", filePtr->name().c_str());
return false;
}
core_trace_scoped(LoadVolumeFormat);
@ -93,7 +93,7 @@ bool loadVolumeFormat(const io::FilePtr& filePtr, voxel::VoxelVolumes& newVolume
return false;
}
if (newVolumes.empty()) {
Log::error("Failed to load model file %s", filePtr->name().c_str());
Log::error("Failed to load model file %s. Broken file.", filePtr->name().c_str());
return false;
}
Log::info("Load model file %s with %i layers", filePtr->name().c_str(), (int)newVolumes.size());

View File

@ -8,6 +8,7 @@
#include "app/App.h"
#include "core/Log.h"
#include "core/Common.h"
#include "core/StringUtil.h"
#include "voxelformat/VolumeFormat.h"
#include "voxelformat/VoxFileFormat.h"
@ -15,9 +16,20 @@ namespace voxedit {
namespace anim {
bool VolumeCache::load(const core::String& fullPath, size_t volumeIndex, voxel::VoxelVolumes& volumes) {
Log::info("Loading volume from %s", fullPath.c_str());
Log::info("Loading volume from %s into the cache", fullPath.c_str());
const io::FilesystemPtr& fs = io::filesystem();
const io::FilePtr& file = fs->open(fullPath);
io::FilePtr file;
for (const char **ext = voxelformat::SUPPORTED_VOXEL_FORMATS_LOAD_LIST; *ext; ++ext) {
file = fs->open(core::string::format("%s.%s", fullPath.c_str(), *ext));
if (file->exists()) {
break;
}
}
if (!file->exists()) {
Log::error("Failed to load %s for any of the supported format extensions", fullPath.c_str());
return false;
}
voxel::VoxelVolumes localVolumes;
// TODO: use the cache luke
if (!voxelformat::loadVolumeFormat(file, localVolumes)) {